mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.11.1.1
This commit is contained in:
@@ -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.htmls.tidy.*; import gplx.xowa.htmls.utils.*; import gplx.xowa.htmls.skins.*;
|
||||
import gplx.xowa.htmls.core.htmls.tidy.*; import gplx.xowa.htmls.js.*; import gplx.xowa.htmls.skins.*;
|
||||
import gplx.xowa.parsers.xndes.*;
|
||||
public class Xoh_html_mgr implements GfoInvkAble {
|
||||
public Xoh_html_mgr(Xoae_app app) {
|
||||
|
||||
70
400_xowa/src/gplx/xowa/htmls/Xoh_page.java
Normal file
70
400_xowa/src/gplx/xowa/htmls/Xoh_page.java
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*; import gplx.xowa.files.*;
|
||||
import gplx.xowa.htmls.heads.*; import gplx.xowa.htmls.sections.*; import gplx.xowa.htmls.core.makes.imgs.*;
|
||||
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;
|
||||
// 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 byte Body_flag() {return body_flag;} private byte body_flag = Byte_.Max_value_127;
|
||||
public Xoh_section_mgr Section_mgr() {return section_mgr;} private final Xoh_section_mgr section_mgr = new Xoh_section_mgr();
|
||||
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 Ordered_hash Redlink_uids() {return redlink_uids;} private final Ordered_hash redlink_uids = Ordered_hash_.New();
|
||||
public int Img_count() {return img_count;} public void Img_count_(int v) {img_count = v;} private int img_count;
|
||||
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_() {}
|
||||
// util
|
||||
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
|
||||
public byte[] Url_bry_safe() {return page_url == null ? Bry_.Empty : page_url.Raw();}
|
||||
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();
|
||||
}
|
||||
public void Ctor_by_db(int head_flag, byte[] display_ttl, byte[] content_sub, byte[] sidebar_div, byte body_flag, 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_flag = body_flag;
|
||||
}
|
||||
public Xoh_page Ctor_by_page(Bry_bfr tmp_bfr, Xoae_page page) {
|
||||
this.page_id = page.Revision_data().Id();
|
||||
this.body = page.Hdump_data().Body();
|
||||
Xopg_html_data html_data = page.Html_data();
|
||||
Xoh_head_mgr mod_mgr = html_data.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);
|
||||
return this;
|
||||
}
|
||||
private void 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();
|
||||
}
|
||||
}
|
||||
@@ -15,13 +15,20 @@ 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.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.*;
|
||||
public class Xow_hzip_itm__file_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xow_hzip_mgr_fxt fxt = new Xow_hzip_mgr_fxt();
|
||||
@Test public void Srl_lnki_img_full() {
|
||||
byte[][] brys = Bry_.Ary(Xow_hzip_dict.Bry_img_full, Bry_.new_ints(7), Bry_.new_ints(12, 0), Bry_.new_a7("cls_other"), Bry_.new_a7("|caption_other"), Xow_hzip_dict.Escape_bry);
|
||||
fxt.Test_save(brys, "<a xtid='a_img_full' xatrs='1|1|1|12|cls_other|caption_other'/>");
|
||||
// fxt.Test_load(brys, "a_1<a href='/wiki/A' title='A'>A</a>a_2");
|
||||
package gplx.xowa.htmls; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*;
|
||||
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();
|
||||
int len = mgr.Count();
|
||||
boolean sidebar_exists = false;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xopg_xtn_skin_itm itm = mgr.Get_at(i);
|
||||
if (itm.Tid() == Xopg_xtn_skin_itm_tid.Tid_sidebar) {
|
||||
sidebar_exists = true;
|
||||
itm.Write(tmp_bfr, page);
|
||||
}
|
||||
}
|
||||
return sidebar_exists ? tmp_bfr.To_bry_and_clear() : 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; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*; import gplx.langs.htmls.*; import gplx.xowa.langs.vnts.*;
|
||||
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.apps.gfs.*; import gplx.xowa.htmls.portal.*;
|
||||
@@ -150,7 +150,7 @@ public class Xoh_page_wtr_wkr implements Bry_fmtr_arg {
|
||||
if (ns_id == Xow_ns_.Id_category) wiki.Html_mgr().Ns_ctg().Bld_html(wiki, page, tidy_bfr);
|
||||
|
||||
// tidy html
|
||||
gplx.xowa.htmls.tidy.Xoh_tidy_mgr tidy_mgr = app.Html_mgr().Tidy_mgr();
|
||||
gplx.xowa.htmls.core.htmls.tidy.Xoh_tidy_mgr tidy_mgr = app.Html_mgr().Tidy_mgr();
|
||||
if (tidy_mgr.Enabled()) tidy_mgr.Run_tidy_html(page, tidy_bfr);
|
||||
|
||||
// add back to main bfr
|
||||
|
||||
@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.htmls; import gplx.*; import gplx.xowa.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.guis.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.htmls.core.htmls.*;
|
||||
public class Xoh_page_wtr_wkr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xoh_page_wtr_fxt fxt = new Xoh_page_wtr_fxt();
|
||||
@Test public void Page_name() {
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.htmls; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.langs.*;
|
||||
import gplx.xowa.wikis.ctgs.*; import gplx.xowa.xtns.gallery.*;
|
||||
import gplx.xowa.htmls.portal.*; import gplx.xowa.htmls.tocs.*; import gplx.xowa.wikis.modules.*; import gplx.xowa.htmls.hzips.*;
|
||||
import gplx.xowa.htmls.portal.*; import gplx.xowa.htmls.tocs.*; import gplx.xowa.wikis.modules.*; import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xow_html_mgr implements GfoInvkAble {
|
||||
public Xow_html_mgr(Xowe_wiki wiki) {
|
||||
this.wiki = wiki;
|
||||
@@ -33,7 +33,6 @@ public class Xow_html_mgr implements GfoInvkAble {
|
||||
portal_mgr = new Xow_portal_mgr(wiki);
|
||||
imgs_mgr = new Xoh_imgs_mgr(this);
|
||||
module_mgr = new Xow_module_mgr(wiki);
|
||||
hzip_mgr = new Xow_hzip_mgr(app.Usr_dlg(), wiki);
|
||||
}
|
||||
public void Init_by_wiki(Xowe_wiki wiki) {
|
||||
html_wtr.Init_by_wiki(wiki);
|
||||
@@ -48,7 +47,6 @@ public class Xow_html_mgr implements GfoInvkAble {
|
||||
public Xow_portal_mgr Portal_mgr() {return portal_mgr;} private Xow_portal_mgr portal_mgr;
|
||||
public Xow_toc_mgr Toc_mgr() {return toc_mgr;} private Xow_toc_mgr toc_mgr = new Xow_toc_mgr();
|
||||
public Xow_module_mgr Head_mgr() {return module_mgr;} private Xow_module_mgr module_mgr;
|
||||
public Xow_hzip_mgr Hzip_mgr() {return hzip_mgr;} private Xow_hzip_mgr hzip_mgr;
|
||||
public boolean Importing_ctgs() {return importing_ctgs;} public void Importing_ctgs_(boolean v) {importing_ctgs = v;} private boolean importing_ctgs;
|
||||
public int Img_thumb_width() {return img_thumb_width;} private int img_thumb_width = 220;
|
||||
public byte[] Img_media_play_btn() {return img_media_play_btn;} private byte[] img_media_play_btn;
|
||||
|
||||
28
400_xowa/src/gplx/xowa/htmls/core/Xoh_html_dict_.java
Normal file
28
400_xowa/src/gplx/xowa/htmls/core/Xoh_html_dict_.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
public class Xoh_html_dict_ {
|
||||
public static final byte[]
|
||||
Type__hdr = Bry_.new_a7(" data-xotype='hdr_bgn'")
|
||||
, Hook__space = Bry_.new_a7(" ")
|
||||
, Hook__lnke = Bry_.new_a7("<a data-xotype='lnke")
|
||||
, Hook__lnki = Bry_.new_a7("<a data-xotype='lnki")
|
||||
, Hdr__end = Bry_.new_a7("<!--xo.hdr-->")
|
||||
, Rng__bgn = Bry_.new_a7("<!--xo.rng.")
|
||||
;
|
||||
}
|
||||
44
400_xowa/src/gplx/xowa/htmls/core/Xow_hdump_mgr.java
Normal file
44
400_xowa/src/gplx/xowa/htmls/core/Xow_hdump_mgr.java
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
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 gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.wikis.data.*;
|
||||
public class Xow_hdump_mgr {
|
||||
private final Xoh_page tmp_hpg = new Xoh_page(); private final Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
public Xow_hdump_mgr(Xow_wiki wiki) {
|
||||
this.hzip_mgr = new Xow_hzip_mgr(wiki);
|
||||
this.save_mgr = new Xow_hdump_mgr__save(wiki, hzip_mgr, tmp_hpg, tmp_bfr);
|
||||
this.load_mgr = new Xow_hdump_mgr__load(wiki, hzip_mgr, tmp_hpg, tmp_bfr);
|
||||
}
|
||||
public void Init_by_db(Xow_wiki wiki) {
|
||||
byte default_zip_tid = gplx.core.ios.Io_stream_.Tid_raw;
|
||||
boolean default_hzip_enable = false;
|
||||
if (wiki.Data__core_mgr() != null) { // TEST: handle null data mgr
|
||||
Xowd_core_db_props props = wiki.Data__core_mgr().Props();
|
||||
default_zip_tid = props.Zip_tid_html();
|
||||
default_hzip_enable = props.Hzip_enabled();
|
||||
}
|
||||
Init_by_db(wiki, default_zip_tid, default_hzip_enable);
|
||||
}
|
||||
public void Init_by_db(Xow_wiki wiki, byte default_zip_tid, boolean default_hzip_enable) {
|
||||
hzip_mgr.Init_by_atrs(default_zip_tid, default_hzip_enable);
|
||||
}
|
||||
public Xow_hzip_mgr Hzip_mgr() {return hzip_mgr;} private Xow_hzip_mgr hzip_mgr;
|
||||
public Xow_hdump_mgr__save Save_mgr() {return save_mgr;} private Xow_hdump_mgr__save save_mgr;
|
||||
public Xow_hdump_mgr__load Load_mgr() {return load_mgr;} private Xow_hdump_mgr__load load_mgr;
|
||||
}
|
||||
75
400_xowa/src/gplx/xowa/htmls/core/Xow_hdump_mgr__load.java
Normal file
75
400_xowa/src/gplx/xowa/htmls/core/Xow_hdump_mgr__load.java
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
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 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.*;
|
||||
public class Xow_hdump_mgr__load {
|
||||
private final Xow_wiki wiki; private final Xow_hzip_mgr hzip_mgr;
|
||||
private final Xoh_page tmp_hpg; private final Xowd_page_itm tmp_dbpg = new Xowd_page_itm();
|
||||
public Xow_hdump_mgr__load(Xow_wiki wiki, Xow_hzip_mgr hzip_mgr, Xoh_page tmp_hpg, Bry_bfr tmp_bfr) {
|
||||
this.wiki = wiki; this.hzip_mgr = hzip_mgr; this.tmp_hpg = tmp_hpg;
|
||||
this.make_mgr = new Xoh_make_mgr(wiki.App().Usr_dlg(), wiki.App().Fsys_mgr(), Xoa_app_.Utl__encoder_mgr().Fsys(), wiki.Domain_bry());
|
||||
}
|
||||
public Xoh_make_mgr Make_mgr() {return make_mgr;} private final Xoh_make_mgr make_mgr;
|
||||
public void Load(Xoae_page wpg) {
|
||||
Load(tmp_hpg, wpg.Ttl());
|
||||
wpg.Hdump_data().Body_(tmp_hpg.Body());
|
||||
// wpg.Root_(new Xop_root_tkn());
|
||||
Fill_page(wpg, tmp_hpg);
|
||||
// foreach (gplx.xowa.htmls.core.makes.imgs.Xohd_img_itm__base itm in hpg.Img_itms())
|
||||
// wpg.Hdump_data().Imgs_add(itm);
|
||||
}
|
||||
public boolean Load(Xoh_page hpg, Xoa_ttl ttl) {
|
||||
synchronized (tmp_dbpg) {
|
||||
if (!Load__dbpg(tmp_dbpg.Clear(), hpg, ttl)) return Load__fail(hpg); // nothing in "page" table
|
||||
Xowd_db_file html_db = wiki.Data__core_mgr().Dbs__get_at(tmp_dbpg.Html_db_id());
|
||||
hpg.Init(hpg.Wiki(), hpg.Url(), ttl, tmp_dbpg.Id());
|
||||
if (!html_db.Tbl__html_page().Select_by_page(hpg)) return Load__fail(hpg); // nothing in "html_page" table
|
||||
byte[] src = hzip_mgr.Parse(hpg.Url_bry_safe(), hpg.Body_flag(), hpg.Body());
|
||||
hpg.Body_(make_mgr.Parse(hpg, src));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
private boolean Load__fail(Xoh_page hpg) {hpg.Exists_n_(); return false;}
|
||||
private boolean Load__dbpg(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(dbpg);
|
||||
return dbpg.Html_db_id() != -1;
|
||||
}
|
||||
private void Load__dbpg__redirects(Xowd_page_itm dbpg) {
|
||||
int redirect_count = 0;
|
||||
while (redirect_count < 5) {
|
||||
int redirect_id = dbpg.Redirect_id();
|
||||
wiki.Data__core_mgr().Tbl__page().Select_by_id(dbpg, redirect_id);
|
||||
if (redirect_id == -1) break;
|
||||
}
|
||||
}
|
||||
private void Fill_page(Xoae_page wpg, Xoh_page hpg) {
|
||||
Xopg_html_data html_data = wpg.Html_data();
|
||||
html_data.Display_ttl_(tmp_hpg.Display_ttl());
|
||||
html_data.Content_sub_(tmp_hpg.Content_sub());
|
||||
html_data.Xtn_skin_mgr().Add(new Xopg_xtn_skin_itm_stub(tmp_hpg.Sidebar_div()));
|
||||
Xoh_head_mgr wpg_head = html_data.Head_mgr();
|
||||
Xopg_module_mgr hpg_head = hpg.Head_mgr();
|
||||
wpg_head.Itm__mathjax().Enabled_ (hpg_head.Math_exists());
|
||||
wpg_head.Itm__popups().Bind_hover_area_ (hpg_head.Imap_exists());
|
||||
wpg_head.Itm__gallery().Enabled_ (hpg_head.Gallery_packed_exists());
|
||||
wpg_head.Itm__hiero().Enabled_ (hpg_head.Hiero_exists());
|
||||
}
|
||||
}
|
||||
@@ -15,11 +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.hdumps; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
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.hdumps.core.*; import gplx.xowa.htmls.hdumps.data.*; import gplx.xowa.htmls.hdumps.pages.*; import gplx.xowa.xtns.hieros.*; import gplx.xowa.xtns.gallery.*;
|
||||
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 Xohd_hdump_wtr_tst {
|
||||
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 Image_full() {
|
||||
// fxt.Expd_itms_xfers(fxt.Make_xfer("A.png", 0, 0, 0, Bool_.Y, Xof_ext_.Id_png));
|
||||
@@ -28,7 +28,7 @@ public class Xohd_hdump_wtr_tst {
|
||||
// , "<a xtid='a_img_full' xatrs='1|0|0||0|test_caption'/>"
|
||||
// );
|
||||
// }
|
||||
@Test public void Image_thumb() {
|
||||
// @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
|
||||
@@ -41,7 +41,7 @@ public class Xohd_hdump_wtr_tst {
|
||||
// , " </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
|
||||
@@ -108,14 +108,15 @@ public class Xohd_hdump_wtr_tst {
|
||||
class Xodb_hdump_mgr__base_fxt {
|
||||
protected Bry_bfr bfr = Bry_bfr.reset_(255);
|
||||
protected Xowe_wiki wiki; protected Xoae_page page;
|
||||
private Xohd_hdump_wtr hdump_wtr;
|
||||
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().Cur_page();
|
||||
hdump_wtr = new Xohd_hdump_wtr(fxt.App(), fxt.Wiki());
|
||||
hdump_mgr = wiki.Html__hdump_mgr();
|
||||
hdump_mgr.Init_by_db(wiki, gplx.core.ios.Io_stream_.Tid_raw, false);
|
||||
}
|
||||
fxt.Reset();
|
||||
page.Revision_data().Id_(0);
|
||||
@@ -125,17 +126,17 @@ class Xodb_hdump_mgr__base_fxt {
|
||||
@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_wtr.Generate_hdump(bfr, page);
|
||||
hdump_mgr.Save_mgr().Make_body_as_hswap(page);
|
||||
}
|
||||
public Xohd_data_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_data_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_data_itm__base.File_repo_id_null, file_ext_id, file_is_orig, html_w, html_uid, html_w, html_h);
|
||||
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_data_itm__base... itms) {expd_itms_xfers.Add_many((Object[])itms);}
|
||||
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) {
|
||||
@@ -151,7 +152,7 @@ class Xohd_hdump_wtr_fxt extends Xodb_hdump_mgr__base_fxt {
|
||||
int len = list.Count();
|
||||
String[] rv = new String[len];
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xohd_data_itm__base itm = (Xohd_data_itm__base)list.Get_at(i);
|
||||
Xohd_img_itm__base itm = (Xohd_img_itm__base)list.Get_at(i);
|
||||
rv[i] = itm.Data_print();
|
||||
}
|
||||
return rv;
|
||||
71
400_xowa/src/gplx/xowa/htmls/core/Xow_hdump_mgr__save.java
Normal file
71
400_xowa/src/gplx/xowa/htmls/core/Xow_hdump_mgr__save.java
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
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 gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.hzips.stats.*; import gplx.xowa.htmls.heads.*;
|
||||
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.pages.*;
|
||||
public class Xow_hdump_mgr__save {
|
||||
private final Xow_wiki wiki; private final Xow_hzip_mgr hzip_mgr;
|
||||
private final Xoh_page tmp_hpg; private final Bry_bfr tmp_bfr; private boolean html_db_is_new = false;
|
||||
public Xow_hdump_mgr__save(Xow_wiki wiki, Xow_hzip_mgr hzip_mgr, Xoh_page tmp_hpg, Bry_bfr tmp_bfr) {
|
||||
this.wiki = wiki; this.hzip_mgr = hzip_mgr;
|
||||
this.tmp_hpg = tmp_hpg; this.tmp_bfr = tmp_bfr;
|
||||
}
|
||||
public int Save(Xoae_page page) {
|
||||
synchronized (tmp_hpg) {
|
||||
Make_body_as_hswap(page);
|
||||
tmp_hpg.Ctor_by_page(tmp_bfr, page);
|
||||
this.html_db_is_new = false;
|
||||
Xowd_db_file html_db = Get_html_db(page);
|
||||
return Save(tmp_hpg, html_db, html_db_is_new);
|
||||
}
|
||||
}
|
||||
public int Save(Xoh_page hpg, Xowd_db_file html_db, boolean insert) {
|
||||
byte db_body_flag = hzip_mgr.Body_flag();
|
||||
byte[] db_body = hzip_mgr.Write(hpg.Url_bry_safe(), db_body_flag, hpg.Body());
|
||||
if (insert)
|
||||
html_db.Tbl__html_page().Insert(hpg, db_body_flag, db_body);
|
||||
else
|
||||
html_db.Tbl__html_page().Update(hpg, db_body_flag, db_body);
|
||||
return db_body.length;
|
||||
}
|
||||
public void Make_body_as_hswap(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, Xoh_wtr_ctx.Hdump, page); // save as hdump_fmt
|
||||
page.Hdump_data().Body_(tmp_bfr.To_bry_and_clear());
|
||||
}
|
||||
private Xowd_db_file Get_html_db(Xoae_page page) {
|
||||
Xowd_db_file rv = Xowd_db_file.Null;
|
||||
Xowd_db_mgr core_data_mgr = wiki.Data__core_mgr();
|
||||
int html_db_id = page.Revision_data().Html_db_id();
|
||||
if (html_db_id == -1) {
|
||||
html_db_is_new = true;
|
||||
rv = core_data_mgr.Db__html();
|
||||
if (rv == null) {
|
||||
rv = core_data_mgr.Dbs__make_by_tid(Xowd_db_file_.Tid_html_data);
|
||||
rv.Tbl__html_redlink().Create_tbl();
|
||||
}
|
||||
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);
|
||||
}
|
||||
else {
|
||||
rv = core_data_mgr.Dbs__get_at(html_db_id);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -15,13 +15,12 @@ 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.hdumps.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hdumps.*;
|
||||
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.bldrs.*; import gplx.xowa.bldrs.wkrs.*; import gplx.xowa.htmls.hdumps.core.*;
|
||||
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 {
|
||||
private Xowd_html_tbl html_tbl;
|
||||
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) {}
|
||||
@@ -33,7 +32,7 @@ class Xob_hdump_img_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
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_new(gplx.dbs.qrys.Db_qry_sql.rdr_(Sql_select)).Exec_select__rls_auto();
|
||||
html_tbl = new Xowd_html_tbl(conn, wiki.Db_mgr_as_sql().Core_data_mgr().Props().Zip_tid_text());
|
||||
// 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");
|
||||
@@ -50,13 +49,13 @@ class Xob_hdump_img_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
// boolean file_is_orig = rdr.Read_int(7) == 1;
|
||||
// double file_time = rdr.Read_double(8);
|
||||
// int file_page = rdr.Read_int(9);
|
||||
// Xohd_data_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);
|
||||
// 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_data_tid.Tid_img, data);
|
||||
// html_tbl.Insert(page_id, Xohd_img_tid.Tid_img, data);
|
||||
}
|
||||
private static final String Sql_select = String_.Concat_lines_nl_skip_last
|
||||
( "SELECT lt.lnki_page_id"
|
||||
@@ -83,15 +82,15 @@ interface Page_async_cmd {
|
||||
void Exec();
|
||||
}
|
||||
class Page_async_cmd__img implements Page_async_cmd {
|
||||
private Xog_page hpg;
|
||||
private Xoh_page hpg;
|
||||
private List_adp missing = List_adp_.new_();
|
||||
public Page_async_cmd__img(Xog_page hpg) {this.hpg = hpg;}
|
||||
public Page_async_cmd__img(Xoh_page hpg) {this.hpg = hpg;}
|
||||
public void Prep() {
|
||||
int len = hpg.Img_count();
|
||||
Xohd_data_itm__base[] ary = hpg.Img_itms();
|
||||
Xohd_img_itm__base[] ary = hpg.Img_itms();
|
||||
missing.Clear();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xohd_data_itm__base itm = ary[i];
|
||||
Xohd_img_itm__base itm = ary[i];
|
||||
boolean exists = Io_mgr.Instance.ExistsFil(itm.Html_view_url());
|
||||
if (!exists) missing.Add(itm);
|
||||
}
|
||||
@@ -99,7 +98,7 @@ class Page_async_cmd__img implements Page_async_cmd {
|
||||
public void Exec() {
|
||||
int len = missing.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
// Xohd_data_itm__base itm = (Xohd_data_itm__base)missing.Get_at(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);
|
||||
}
|
||||
53
400_xowa/src/gplx/xowa/htmls/core/bldrs/Xob_hdump_mgr.java
Normal file
53
400_xowa/src/gplx/xowa/htmls/core/bldrs/Xob_hdump_mgr.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
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.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.stats.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.data.*;
|
||||
public class Xob_hdump_mgr {
|
||||
private final Xowe_wiki wiki; private final Xow_hdump_mgr hdump_mgr;
|
||||
private final Xob_ns_to_db_mgr ns_to_db_mgr; int prv_row_len = 0;
|
||||
private final Hzip_stat_tbl stats_tbl; private final Hzip_stat_itm tmp_stat_itm;
|
||||
private final Xoh_page tmp_hpg = new Xoh_page(); private final Bry_bfr tmp_bfr = Bry_bfr.reset_(Io_mgr.Len_mb);
|
||||
public Xob_hdump_mgr(Xowe_wiki wiki, Db_conn make_conn, long hdump_db_max, byte zip_tid, boolean hzip_enabled) {
|
||||
this.wiki = wiki; this.hdump_mgr = wiki.Html__hdump_mgr(); this.tmp_stat_itm = hdump_mgr.Hzip_mgr().Stat_itm();
|
||||
hdump_mgr.Hzip_mgr().Init_by_atrs(zip_tid, hzip_enabled);
|
||||
this.stats_tbl = new Hzip_stat_tbl(make_conn);
|
||||
Xowd_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, hdump_db_max);
|
||||
Xob_ns_file_itm.Init_ns_bldr_data(Xowd_db_file_.Tid_html_data, wiki.Ns_mgr(), gplx.xowa.apps.apis.xowa.bldrs.imports.Xoapi_import.Ns_file_map__each);
|
||||
}
|
||||
public void Insert(Xoae_page page) {
|
||||
Make_page_body(page);
|
||||
Xowd_db_file html_db = ns_to_db_mgr.Get_by_ns(page.Ttl().Ns().Bldr_data(), prv_row_len); // get html_db
|
||||
synchronized (tmp_hpg) {
|
||||
this.prv_row_len = hdump_mgr.Save_mgr().Save(tmp_hpg.Ctor_by_page(tmp_bfr, page), html_db, true); // save to db
|
||||
}
|
||||
stats_tbl.Insert(tmp_hpg, tmp_stat_itm, page.Root().Root_src().length, tmp_hpg.Body().length, prv_row_len); // save stats
|
||||
}
|
||||
public void Bld_term() {this.Commit(); ns_to_db_mgr.Rls_all();}
|
||||
public void Commit() {
|
||||
ns_to_db_mgr.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 Make_page_body(Xoae_page page) {
|
||||
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, Xoh_wtr_ctx.Hdump, page); // write to html again, except in hdump mode
|
||||
page.Hdump_data().Body_(tmp_bfr.To_bry_and_clear()); // write to body bry
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.hdumps.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hdumps.*;
|
||||
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.*;
|
||||
public class Xob_link_dump_cmd {
|
||||
private Xob_link_dump_tbl tbl; private int src_page_id; private Io_url page_db_url;
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.hdumps.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hdumps.*;
|
||||
package gplx.xowa.htmls.core.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.dbs.*;
|
||||
class Xob_link_dump_tbl implements RlsAble {
|
||||
public static final String Tbl_name = "link_dump"; private static final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
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.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 {
|
||||
private final Xowd_db_file page_db;
|
||||
public Xob_ns_to_db_wkr__html(Xowd_db_file page_db) {this.page_db = page_db;}
|
||||
public byte Db_tid() {return Xowd_db_file_.Tid_html_data;}
|
||||
public void Tbl_init(Xowd_db_file db) {
|
||||
Xoh_page_tbl tbl = db.Tbl__html_page();
|
||||
tbl.Create_tbl();
|
||||
tbl.Insert_bgn();
|
||||
}
|
||||
public void Tbl_term(Xowd_db_file db) {
|
||||
db.Tbl__text().Insert_end();
|
||||
Db_conn db_conn = db.Conn();
|
||||
Db_attach_cmd.new_(page_db.Conn(), "html_db", db.Url())
|
||||
.Add_fmt("hdump.update page.html_db_id", Sql_update_page_html_db_id, db.Id())
|
||||
.Exec();
|
||||
db_conn.Rls_conn();
|
||||
}
|
||||
private static final String Sql_update_page_html_db_id = String_.Concat_lines_nl_skip_last
|
||||
( "REPLACE INTO page (page_id, page_namespace, page_title, page_is_redirect, page_touched, page_len, page_random_int, page_text_db_id, page_html_db_id, page_redirect_id)"
|
||||
, "SELECT p.page_id"
|
||||
, ", p.page_namespace"
|
||||
, ", p.page_title"
|
||||
, ", p.page_is_redirect"
|
||||
, ", p.page_touched"
|
||||
, ", p.page_len"
|
||||
, ", p.page_random_int"
|
||||
, ", p.page_text_db_id"
|
||||
, ", {0}"
|
||||
, ", p.page_redirect_id"
|
||||
, "FROM page p"
|
||||
, " JOIN <attach_db>html_page h ON p.page_id = h.page_id"
|
||||
);
|
||||
}
|
||||
@@ -15,10 +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.hdumps.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hdumps.*;
|
||||
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.bldrs.wkrs.*; import gplx.xowa.htmls.hdumps.data.*;
|
||||
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*;
|
||||
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.htmls.core.dbs.*;
|
||||
public class Xob_redlink_mkr_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
private int commit_interval = 10000, commit_count = 0;
|
||||
public Xob_redlink_mkr_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
|
||||
@@ -32,23 +33,23 @@ public class Xob_redlink_mkr_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
Db_attach_rdr attach_rdr = new Db_attach_rdr(link_dump_db.Conn(), "page_db", core_db.Url());
|
||||
attach_rdr.Attach();
|
||||
Xowd_page_tbl page_tbl = core_db.Tbl__page();
|
||||
int cur_html_db_id = -1, cur_page_id = -1; Xowd_html_tbl html_dump_tbl = null;
|
||||
int cur_html_db_id = -1, cur_page_id = -1; Xoh_redlink_tbl redlink_tbl = null;
|
||||
Db_rdr rdr = attach_rdr.Exec_as_rdr(Sql_select);
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
// switch html_db if needed
|
||||
int html_db_id = rdr.Read_int(page_tbl.Fld_html_db_id());
|
||||
if (html_db_id != cur_html_db_id) {
|
||||
if (html_dump_tbl != null) html_dump_tbl.Conn().Txn_end();
|
||||
html_dump_tbl = wiki.Data__core_mgr().Dbs__get_at(html_db_id).Tbl__html();
|
||||
html_dump_tbl.Conn().Txn_bgn("bldr__redlink");
|
||||
if (redlink_tbl != null) redlink_tbl.Conn().Txn_end();
|
||||
redlink_tbl = wiki.Data__core_mgr().Dbs__get_at(html_db_id).Tbl__html_redlink();
|
||||
redlink_tbl.Conn().Txn_bgn("bldr__redlink");
|
||||
cur_html_db_id = html_db_id;
|
||||
}
|
||||
// commit page_id if needed
|
||||
int page_id = rdr.Read_int(page_tbl.Fld_page_id());
|
||||
if (cur_page_id != page_id) {
|
||||
if (cur_page_id != -1) Commit(html_dump_tbl, cur_page_id, bfr);
|
||||
bfr.Add_int_variable(gplx.xowa.htmls.hdumps.core.Xohd_data_tid.Tid_redlink).Add_byte_pipe();
|
||||
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();
|
||||
cur_page_id = page_id;
|
||||
}
|
||||
// add html_uid to cur_page's bfr
|
||||
@@ -57,15 +58,15 @@ public class Xob_redlink_mkr_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
}
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
Commit(html_dump_tbl, cur_page_id, bfr); // commit cur page
|
||||
html_dump_tbl.Conn().Txn_end(); // close cur tbl
|
||||
Commit(redlink_tbl, cur_page_id, bfr); // commit cur page
|
||||
redlink_tbl.Conn().Txn_end(); // close cur tbl
|
||||
attach_rdr.Detach();
|
||||
}
|
||||
private void Commit(Xowd_html_tbl html_dump_tbl, int cur_page_id, Bry_bfr bfr) {
|
||||
html_dump_tbl.Insert(cur_page_id, Xowd_html_row.Tid_redlink, bfr.To_bry_and_clear());
|
||||
private void Commit(Xoh_redlink_tbl redlink_tbl, int cur_page_id, Bry_bfr bfr) {
|
||||
redlink_tbl.Insert(cur_page_id, bfr.To_bry_and_clear());
|
||||
++commit_count;
|
||||
if ((commit_count % commit_interval ) == 0)
|
||||
html_dump_tbl.Conn().Txn_sav();
|
||||
redlink_tbl.Conn().Txn_sav();
|
||||
}
|
||||
private static final String Sql_select = String_.Concat_lines_nl_skip_last
|
||||
( "SELECT p.page_html_db_id"
|
||||
79
400_xowa/src/gplx/xowa/htmls/core/dbs/Xoh_page_tbl.java
Normal file
79
400_xowa/src/gplx/xowa/htmls/core/dbs/Xoh_page_tbl.java
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
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.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.dbs.*;
|
||||
public class Xoh_page_tbl implements RlsAble {
|
||||
private final String tbl_name = "html_page"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_page_id, fld_head_flag, fld_body_flag, fld_display_ttl, fld_content_sub, fld_sidebar_div, fld_body;
|
||||
private final Db_conn conn; private Db_stmt stmt_select, stmt_insert, stmt_delete, stmt_update;
|
||||
public Xoh_page_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");
|
||||
this.fld_body_flag = flds.Add_int("body_flag");
|
||||
this.fld_display_ttl = flds.Add_str("display_ttl", 1024);
|
||||
this.fld_content_sub = flds.Add_str("content_sub", 1024);
|
||||
this.fld_sidebar_div = flds.Add_str("sidebar_div", 2048);
|
||||
this.fld_body = flds.Add_bry("body");
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public Db_conn Conn() {return conn;}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Db_meta_tbl.new_(tbl_name, flds));}
|
||||
public void Insert_bgn() {conn.Txn_bgn("html_page__insert"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_end() {conn.Txn_end(); stmt_insert = Db_stmt_.Rls(stmt_insert);}
|
||||
public void Insert(Xoh_page hpg, byte db_body_flag, byte[] body) {Insert(hpg.Page_id(), hpg.Head_mgr().Flag(), db_body_flag, hpg.Display_ttl(), hpg.Content_sub(), hpg.Sidebar_div(), body);}
|
||||
public void Insert(int page_id, int head_flag, int body_flag, byte[] display_ttl, byte[] content_sub, byte[] sidebar_div, byte[] body) {
|
||||
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
stmt_insert.Clear().Val_int(fld_page_id, page_id);
|
||||
Fill_stmt(stmt_insert, head_flag, body_flag, display_ttl, content_sub, sidebar_div, body);
|
||||
stmt_insert.Exec_insert();
|
||||
}
|
||||
public void Update(Xoh_page hpg, byte db_body_flag, byte[] body) {Update(hpg.Page_id(), hpg.Head_mgr().Flag(), db_body_flag, hpg.Display_ttl(), hpg.Content_sub(), hpg.Sidebar_div(), body);}
|
||||
public void Update(int page_id, int head_flag, int body_flag, byte[] display_ttl, byte[] content_sub, byte[] sidebar_div, byte[] body) {
|
||||
if (stmt_update == null) stmt_update = conn.Stmt_update_exclude(tbl_name, flds, fld_page_id);
|
||||
stmt_update.Clear();
|
||||
Fill_stmt(stmt_update, head_flag, body_flag, display_ttl, content_sub, sidebar_div, body);
|
||||
stmt_update.Crt_int(fld_page_id, page_id).Exec_update();
|
||||
}
|
||||
public void Delete(int page_id) {
|
||||
if (stmt_delete == null) stmt_delete = conn.Stmt_delete(tbl_name, fld_page_id);
|
||||
stmt_delete.Clear().Crt_int(fld_page_id, page_id).Exec_delete();
|
||||
}
|
||||
public boolean Select_by_page(Xoh_page hpg) {
|
||||
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, hpg.Page_id()).Exec_select__rls_manual();
|
||||
try {
|
||||
if (rdr.Move_next()) {
|
||||
hpg.Ctor_by_db(rdr.Read_int(fld_head_flag), rdr.Read_bry_by_str(fld_display_ttl), rdr.Read_bry_by_str(fld_content_sub), rdr.Read_bry_by_str(fld_sidebar_div), (byte)rdr.Read_int(fld_body_flag), rdr.Read_bry(fld_body));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
stmt_delete = Db_stmt_.Rls(stmt_delete);
|
||||
stmt_select = Db_stmt_.Rls(stmt_select);
|
||||
stmt_update = Db_stmt_.Rls(stmt_update);
|
||||
}
|
||||
private void Fill_stmt(Db_stmt stmt, int head_flag, int body_flag, byte[] display_ttl, byte[] content_sub, byte[] sidebar_div, byte[] body) {
|
||||
stmt.Val_int(fld_head_flag, head_flag).Val_int(fld_body_flag, body_flag)
|
||||
.Val_bry_as_str(fld_display_ttl, Bry_.Coalesce_to_empty(display_ttl)).Val_bry_as_str(fld_content_sub, Bry_.Coalesce_to_empty(content_sub)).Val_bry_as_str(fld_sidebar_div, Bry_.Coalesce_to_empty(sidebar_div)).Val_bry(fld_body, body);
|
||||
}
|
||||
}
|
||||
60
400_xowa/src/gplx/xowa/htmls/core/dbs/Xoh_redlink_tbl.java
Normal file
60
400_xowa/src/gplx/xowa/htmls/core/dbs/Xoh_redlink_tbl.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
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.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.dbs.*;
|
||||
public class Xoh_redlink_tbl implements RlsAble {
|
||||
private final String tbl_name = "html_redlink"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_page_id, fld_redlink_uids;
|
||||
private final Db_conn conn; private Db_stmt stmt_select, stmt_insert, stmt_delete, stmt_update;
|
||||
public Xoh_redlink_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.fld_page_id = flds.Add_int_pkey("page_id");
|
||||
this.fld_redlink_uids = flds.Add_bry("redlink_uids");
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public Db_conn Conn() {return conn;}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Db_meta_tbl.new_(tbl_name, flds));}
|
||||
public void Insert_bgn() {conn.Txn_bgn("html_redlink__insert"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_end() {conn.Txn_end(); stmt_insert = Db_stmt_.Rls(stmt_insert);}
|
||||
public void Insert(int page_id, byte[] redlink_uids) {
|
||||
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
stmt_insert.Clear().Val_int(fld_page_id, page_id).Val_bry(fld_redlink_uids, redlink_uids).Exec_insert();
|
||||
}
|
||||
public void Update(int page_id, byte[] redlink_uids) {
|
||||
if (stmt_update == null) stmt_update = conn.Stmt_update_exclude(tbl_name, flds, fld_page_id);
|
||||
stmt_update.Clear().Val_bry(fld_redlink_uids, redlink_uids).Crt_int(fld_page_id, page_id).Exec_update();
|
||||
}
|
||||
public void Delete(int page_id) {
|
||||
if (stmt_delete == null) stmt_delete = conn.Stmt_delete(tbl_name, fld_page_id);
|
||||
stmt_delete.Clear().Crt_int(fld_page_id, page_id).Exec_delete();
|
||||
}
|
||||
public byte[] Select_or_null(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 {
|
||||
return rdr.Move_next() ? rdr.Read_bry(fld_redlink_uids) : null;
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
stmt_delete = Db_stmt_.Rls(stmt_delete);
|
||||
stmt_select = Db_stmt_.Rls(stmt_select);
|
||||
stmt_update = Db_stmt_.Rls(stmt_update);
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,14 @@ 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; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.htmls.core.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.core.primitives.*; import gplx.core.net.*; import gplx.core.btries.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.langs.*; import gplx.xowa.langs.kwds.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.apos.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.lnkes.*; import gplx.xowa.parsers.hdrs.*; import gplx.xowa.parsers.lists.*; import gplx.xowa.htmls.lnkis.*; import gplx.xowa.parsers.tblws.*; import gplx.xowa.parsers.paras.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.lnkis.*; import gplx.xowa.parsers.miscs.*; import gplx.xowa.parsers.vnts.*; import gplx.xowa.parsers.htmls.*;
|
||||
import gplx.xowa.xtns.*; import gplx.xowa.xtns.dynamicPageList.*; import gplx.xowa.xtns.math.*; import gplx.xowa.xtns.cite.*; import gplx.xowa.htmls.hzips.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.apos.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.lnkes.*; import gplx.xowa.parsers.lists.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*; import gplx.xowa.parsers.tblws.*; import gplx.xowa.parsers.paras.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.lnkis.*; import gplx.xowa.parsers.miscs.*; import gplx.xowa.parsers.vnts.*; import gplx.xowa.parsers.htmls.*;
|
||||
import gplx.xowa.xtns.*; import gplx.xowa.xtns.dynamicPageList.*; import gplx.xowa.xtns.math.*; import gplx.xowa.xtns.cite.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.parsers.hdrs.*;
|
||||
import gplx.xowa.htmls.core.*;
|
||||
import gplx.xowa.htmls.core.wkrs.hdrs.*; import gplx.xowa.htmls.core.wkrs.lnkes.*;
|
||||
public class Xoh_html_wtr {
|
||||
private Xowe_wiki wiki; private Xoae_app app; private Xoae_page page; private Xop_xatr_whitelist_mgr whitelist_mgr;
|
||||
public Xoh_html_wtr(Xowe_wiki wiki, Xow_html_mgr html_mgr) {
|
||||
@@ -28,16 +30,16 @@ public class Xoh_html_wtr {
|
||||
this.html_mgr = html_mgr;
|
||||
lnki_wtr = new Xoh_lnki_wtr(this, wiki, html_mgr, cfg);
|
||||
ref_wtr = new Ref_html_wtr(wiki);
|
||||
lnke_wtr = new Xoh_lnke_wtr(wiki);
|
||||
}
|
||||
public void Init_by_wiki(Xowe_wiki wiki) {
|
||||
cfg.Toc__show_(Bool_.Y).Lnki__title_(true).Lnki_visited_y_().Lnki__id_y_(); // NOTE: set during Init_by_wiki, b/c all tests assume these are false
|
||||
cfg.Toc__show_(Bool_.Y).Lnki__title_(true).Lnki_visited_y_().Lnki__id_(Bool_.Y); // NOTE: set during Init_by_wiki, b/c all tests assume these are false
|
||||
ref_wtr.Init_by_wiki(wiki);
|
||||
}
|
||||
public Xow_html_mgr Html_mgr() {return html_mgr;} private Xow_html_mgr html_mgr;
|
||||
public Xoh_html_wtr_cfg Cfg() {return cfg;} private Xoh_html_wtr_cfg cfg = new Xoh_html_wtr_cfg();
|
||||
public Xoh_lnke_html Wkr__lnke() {return wkr__lnke;} private Xoh_lnke_html wkr__lnke = new Xoh_lnke_html();
|
||||
public Xoh_hdr_html Wkr__hdr() {return wkr__hdr;} private final Xoh_hdr_html wkr__hdr = new Xoh_hdr_html();
|
||||
public Xoh_lnki_wtr Lnki_wtr() {return lnki_wtr;} private Xoh_lnki_wtr lnki_wtr;
|
||||
public Xoh_lnke_wtr Lnke_wtr() {return lnke_wtr;} private Xoh_lnke_wtr lnke_wtr;
|
||||
public Ref_html_wtr Ref_wtr() {return ref_wtr;} private Ref_html_wtr ref_wtr;
|
||||
public void Init_by_page(Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xoae_page page) {this.page = page; lnki_wtr.Init_by_page(ctx, hctx, src, page);}
|
||||
public void Write_all(Bry_bfr bfr, Xop_ctx ctx, byte[] src, Xop_root_tkn root) {Write_all(bfr, ctx, Xoh_wtr_ctx.Basic, src, root);}
|
||||
@@ -47,8 +49,6 @@ public class Xoh_html_wtr {
|
||||
page.Slink_list().Clear(); // HACK: always clear langs; necessary for reload
|
||||
lnki_wtr.Init_by_page(ctx, hctx, src, ctx.Cur_page());
|
||||
Write_tkn(bfr, ctx, hctx, src, null, -1, root);
|
||||
if (cfg.Hdr__div_wrapper())
|
||||
bfr.Add(Tag_hdr__div_wrapper_end);
|
||||
}
|
||||
finally {
|
||||
page.Category_list_(page.Html_data().Ctgs_to_ary());
|
||||
@@ -74,9 +74,7 @@ public class Xoh_html_wtr {
|
||||
case Xop_tkn_itm_.Tid_html_ncr: Html_ncr(ctx, hctx, bfr, src, (Xop_amp_tkn_num)tkn); break;
|
||||
case Xop_tkn_itm_.Tid_html_ref: Html_ref(ctx, hctx, bfr, src, (Xop_amp_tkn_txt)tkn); break;
|
||||
case Xop_tkn_itm_.Tid_hr: Hr(ctx, hctx, bfr, src, (Xop_hr_tkn)tkn); break;
|
||||
case Xop_tkn_itm_.Tid_hdr: Hdr(ctx, hctx, bfr, src, (Xop_hdr_tkn)tkn); break;
|
||||
case Xop_tkn_itm_.Tid_apos: Apos(ctx, hctx, bfr, src, (Xop_apos_tkn)tkn); break;
|
||||
case Xop_tkn_itm_.Tid_lnke: lnke_wtr.Write_all(bfr, this, hctx, ctx, src, (Xop_lnke_tkn)tkn); break;
|
||||
case Xop_tkn_itm_.Tid_lnki: lnki_wtr.Write(bfr, hctx, src, (Xop_lnki_tkn)tkn); break;
|
||||
case Xop_tkn_itm_.Tid_list: List(ctx, hctx, bfr, src, (Xop_list_tkn)tkn); break;
|
||||
case Xop_tkn_itm_.Tid_xnde: Xnde(ctx, hctx, bfr, src, (Xop_xnde_tkn)tkn); break;
|
||||
@@ -86,64 +84,30 @@ public class Xoh_html_wtr {
|
||||
case Xop_tkn_itm_.Tid_tblw_td: Tblw(ctx, hctx, bfr, src, (Xop_tblw_tkn)tkn, Tag_tblw_td_bgn_atr, Tag_tblw_td_end, false); break;
|
||||
case Xop_tkn_itm_.Tid_tblw_th: Tblw(ctx, hctx, bfr, src, (Xop_tblw_tkn)tkn, Tag_tblw_th_bgn_atr, Tag_tblw_th_end, false); break;
|
||||
case Xop_tkn_itm_.Tid_tblw_tc: Tblw(ctx, hctx, bfr, src, (Xop_tblw_tkn)tkn, Tag_tblw_tc_bgn_atr, Tag_tblw_tc_end, false); break;
|
||||
case Xop_tkn_itm_.Tid_para: Para(ctx, hctx, bfr, src, (Xop_para_tkn)tkn); break;
|
||||
case Xop_tkn_itm_.Tid_space: Space(ctx, hctx, bfr, src, grp, sub_idx, (Xop_space_tkn)tkn); break;
|
||||
case Xop_tkn_itm_.Tid_pre: Pre(ctx, hctx, bfr, src, (Xop_pre_tkn)tkn); break;
|
||||
case Xop_tkn_itm_.Tid_newLine: NewLine(ctx, hctx, bfr, src, (Xop_nl_tkn)tkn); break;
|
||||
case Xop_tkn_itm_.Tid_bry: Bry(ctx, hctx, bfr, src, (Xop_bry_tkn)tkn); break;
|
||||
case Xop_tkn_itm_.Tid_lnke: wkr__lnke.Write_html(bfr, this, hctx, ctx, src, (Xop_lnke_tkn)tkn); break;
|
||||
case Xop_tkn_itm_.Tid_hdr: wkr__hdr.Write_html(bfr, this, wiki, page, ctx, hctx, cfg, grp, sub_idx, src, (Xop_hdr_tkn)tkn); break;
|
||||
case Xop_tkn_itm_.Tid_para:
|
||||
case Xop_tkn_itm_.Tid_pre:
|
||||
case Xop_tkn_itm_.Tid_space:
|
||||
case Xop_tkn_itm_.Tid_escape:
|
||||
tkn.Html__write(bfr, this, wiki, page, ctx, hctx, cfg, grp, sub_idx, src); break;
|
||||
default:
|
||||
Xoh_html_wtr_escaper.Escape(app.Parser_amp_mgr(), bfr, src, tkn.Src_bgn(), tkn.Src_end(), true, false); // NOTE: always escape text including (a) lnki_alt text; and (b) any other text, especially failed xndes; DATE:2013-06-18
|
||||
break;
|
||||
}
|
||||
}
|
||||
@gplx.Virtual public void Html_ncr(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_amp_tkn_num tkn) {
|
||||
public void Html_ncr(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_amp_tkn_num tkn) {
|
||||
bfr.Add_byte(Byte_ascii.Amp).Add_byte(Byte_ascii.Hash).Add_int_variable(tkn.Val()).Add_byte(Byte_ascii.Semic); // NOTE: do not literalize, else browser may not display multi-char bytes properly; EX:   gets added as   not as {192,160}; DATE:2013-12-09
|
||||
}
|
||||
@gplx.Virtual public void Html_ref(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_amp_tkn_txt tkn) {
|
||||
public void Html_ref(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_amp_tkn_txt tkn) {
|
||||
if (tkn.Itm_is_custom()) // used by <nowiki>; EX:<nowiki><</nowiki> -> &xowa_lt; DATE:2014-11-07
|
||||
tkn.Print_literal(bfr);
|
||||
else
|
||||
tkn.Print_ncr(bfr);
|
||||
}
|
||||
private static final byte[] Bry_hdr_bgn = Bry_.new_a7("<span class='mw-headline' id='"), Bry_hdr_end = Bry_.new_a7("</span>");
|
||||
@gplx.Virtual public void Hr(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_hr_tkn tkn) {bfr.Add(Tag_hr);}
|
||||
@gplx.Virtual public void Hdr(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_hdr_tkn hdr) {
|
||||
boolean hdr_is_1st = hdr.Hdr_html_first();
|
||||
if (hdr_is_1st && 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.Cur_page(), hctx, src, bfr);
|
||||
}
|
||||
int hdr_len = hdr.Hdr_len();
|
||||
if (hdr_len > 0) { // NOTE: need to check hdr_len b/c it could be dangling
|
||||
Para_assert_tag_starts_on_nl(bfr, hdr.Src_bgn());
|
||||
if ( cfg.Hdr__div_wrapper() // div_wrapper enabled
|
||||
&& !hdr_is_1st // not 1st <h#>; 2nd and up will close previous <#>
|
||||
)
|
||||
bfr.Add(Tag_hdr__div_wrapper_end); // add </div>
|
||||
bfr.Add(Tag_hdr_bgn).Add_int(hdr_len, 1, 1);
|
||||
if (cfg.Toc__show()) {
|
||||
bfr.Add_byte(Tag__end);
|
||||
bfr.Add(Bry_hdr_bgn);
|
||||
bfr.Add(hdr.Hdr_html_id());
|
||||
bfr.Add_byte(Byte_ascii.Apos);
|
||||
}
|
||||
bfr.Add_byte(Tag__end);
|
||||
}
|
||||
if (hdr.Hdr_bgn_manual() > 0) bfr.Add_byte_repeat(Byte_ascii.Eq, hdr.Hdr_bgn_manual());
|
||||
int subs_len = hdr.Subs_len();
|
||||
for (int i = 0; i < subs_len; i++)
|
||||
Write_tkn(bfr, ctx, hctx, src, hdr, i, hdr.Subs_get(i));
|
||||
if (hdr_len > 0) { // NOTE: need to check hdr_len b/c it could be dangling
|
||||
if (hdr.Hdr_end_manual() > 0) bfr.Add_byte_repeat(Byte_ascii.Eq, hdr.Hdr_end_manual());
|
||||
if (cfg.Toc__show()) {
|
||||
if (hctx.Mode_is_hdump())
|
||||
bfr.Add(Xow_hzip_itm__header.Hdr_end);
|
||||
bfr.Add(Bry_hdr_end);
|
||||
}
|
||||
bfr.Add(Tag_hdr_end).Add_int(hdr_len, 1, 1).Add_byte(Tag__end).Add_byte_nl();// NOTE: do not need to check hdr_len b/c it is impossible for end to occur without bgn
|
||||
if ( cfg.Hdr__div_wrapper()) // div_wrapper enabled
|
||||
bfr.Add(Tag_hdr__div_wrapper_bgn); // add <div>
|
||||
}
|
||||
}
|
||||
public void Hr(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_hr_tkn tkn) {bfr.Add(Tag_hr);}
|
||||
public void Apos(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_apos_tkn apos) {
|
||||
if (hctx.Mode_is_alt()) return; // ignore apos if alt; EX: [[File:A.png|''A'']] should have alt of A; DATE:2013-10-25
|
||||
int literal_apos = apos.Apos_lit();
|
||||
@@ -186,7 +150,7 @@ public class Xoh_html_wtr {
|
||||
}
|
||||
}
|
||||
}
|
||||
@gplx.Virtual public void List_grp_bgn(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, byte type) {
|
||||
public void List_grp_bgn(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, byte type) {
|
||||
byte[] tag = null;
|
||||
switch (type) {
|
||||
case Xop_list_tkn_.List_itmTyp_ol: tag = Tag_list_grp_ol_bgn; break;
|
||||
@@ -200,7 +164,7 @@ public class Xoh_html_wtr {
|
||||
bfr.Add(tag);
|
||||
++indent_level;
|
||||
}
|
||||
@gplx.Virtual public void List_itm_bgn(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, byte type) {
|
||||
public void List_itm_bgn(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, byte type) {
|
||||
byte[] tag = null;
|
||||
switch (type) {
|
||||
case Xop_list_tkn_.List_itmTyp_ol:
|
||||
@@ -214,7 +178,7 @@ public class Xoh_html_wtr {
|
||||
bfr.Add(tag);
|
||||
++indent_level;
|
||||
}
|
||||
@gplx.Virtual public void List_grp_end(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, byte type) {
|
||||
public void List_grp_end(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, byte type) {
|
||||
--indent_level;
|
||||
byte[] tag = null;
|
||||
switch (type) {
|
||||
@@ -229,7 +193,7 @@ public class Xoh_html_wtr {
|
||||
bfr.Add(tag);
|
||||
}
|
||||
|
||||
@gplx.Virtual public void List_itm_end(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, byte type) {
|
||||
public void List_itm_end(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, byte type) {
|
||||
--indent_level;
|
||||
byte[] tag = null;
|
||||
switch (type) {
|
||||
@@ -243,7 +207,7 @@ public class Xoh_html_wtr {
|
||||
if (indent_level > 0) bfr.Add_byte_repeat(Byte_ascii.Space, indent_level * 2);
|
||||
bfr.Add(tag);
|
||||
}
|
||||
@gplx.Virtual public void NewLine(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_nl_tkn tkn) {
|
||||
public void NewLine(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_nl_tkn tkn) {
|
||||
if (hctx.Mode_is_alt())
|
||||
bfr.Add_byte_space();
|
||||
else {
|
||||
@@ -252,49 +216,10 @@ public class Xoh_html_wtr {
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Space(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_tkn_grp grp, int sub_idx, Xop_space_tkn space) {
|
||||
bfr.Add_byte_repeat(Byte_ascii.Space, space.Src_end_grp(grp, sub_idx) - space.Src_bgn_grp(grp, sub_idx)); // NOTE: lnki.caption will convert \n to \s; see Xop_nl_lxr; PAGE:en.w:Schwarzschild radius
|
||||
}
|
||||
@gplx.Virtual public void Para(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_para_tkn para) {
|
||||
if (para.Nl_bgn() && bfr.Len() > 0) {
|
||||
if (hctx.Mode_is_alt())
|
||||
bfr.Add_byte_space();
|
||||
else
|
||||
bfr.Add_byte_if_not_last(Byte_ascii.Nl);
|
||||
}
|
||||
switch (para.Para_end()) {
|
||||
case Xop_para_tkn.Tid_none: break;
|
||||
case Xop_para_tkn.Tid_para: bfr.Add(Tag_para_end).Add_byte_nl(); break;
|
||||
case Xop_para_tkn.Tid_pre: bfr.Add(Tag_pre_end).Add_byte_nl(); break;
|
||||
default: throw Err_.new_unhandled(para.Para_end());
|
||||
}
|
||||
switch (para.Para_bgn()) {
|
||||
case Xop_para_tkn.Tid_none: break;
|
||||
case Xop_para_tkn.Tid_para: Para_assert_tag_starts_on_nl(bfr, para.Src_bgn()); bfr.Add(Tag_para_bgn); break;
|
||||
case Xop_para_tkn.Tid_pre: Para_assert_tag_starts_on_nl(bfr, para.Src_bgn()); bfr.Add(Tag_pre_bgn); break;
|
||||
default: throw Err_.new_unhandled(para.Para_bgn());
|
||||
}
|
||||
if (para.Space_bgn() > 0)
|
||||
bfr.Add_byte_repeat(Byte_ascii.Space, para.Space_bgn());
|
||||
}
|
||||
private void Para_assert_tag_starts_on_nl(Bry_bfr bfr, int src_bgn) {
|
||||
if (!bfr.Match_end_byt_nl_or_bos()) bfr.Add_byte_nl();
|
||||
if (src_bgn != 0) bfr.Add_byte_nl();
|
||||
}
|
||||
@gplx.Virtual public void Pre(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_pre_tkn pre) {
|
||||
switch (pre.Pre_tid()) {
|
||||
case Xop_pre_tkn.Pre_tid_bgn:
|
||||
bfr.Add(Tag_pre_bgn);
|
||||
break;
|
||||
case Xop_pre_tkn.Pre_tid_end:
|
||||
bfr.Add_byte_nl().Add(Tag_pre_end).Add_byte_nl().Add_byte_nl();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@gplx.Virtual public void Bry(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_bry_tkn bry) {
|
||||
public void Bry(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_bry_tkn bry) {
|
||||
bfr.Add(bry.Val());
|
||||
}
|
||||
@gplx.Virtual public void Under(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_under_tkn under) {
|
||||
public void Under(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_under_tkn under) {
|
||||
if (hctx.Mode_is_alt()) return;
|
||||
switch (under.Under_tid()) {
|
||||
case Xol_kwd_grp_.Id_toc:
|
||||
@@ -304,7 +229,7 @@ public class Xoh_html_wtr {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@gplx.Virtual public void Xnde(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_xnde_tkn xnde) {
|
||||
public void Xnde(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_xnde_tkn xnde) {
|
||||
if (hctx.Mode_is_alt()) {
|
||||
if (xnde.Tag_close_bgn() > 0) // NOTE: some tags are not closed; WP.EX: France; <p>
|
||||
Xoh_html_wtr_escaper.Escape(app.Parser_amp_mgr(), bfr, src, xnde.Tag_open_end(), xnde.Tag_close_bgn(), true, false);
|
||||
@@ -348,11 +273,11 @@ public class Xoh_html_wtr {
|
||||
case Xop_xnde_tag_.Tid_pre: {
|
||||
if (xnde.Tag_open_end() == xnde.Tag_close_bgn()) return; // ignore empty tags, else blank pre line will be printed; DATE:2014-03-12
|
||||
byte[] name = tag.Name_bry();
|
||||
bfr.Add_byte(Tag__bgn).Add(name);
|
||||
bfr.Add_byte(Byte_ascii.Angle_bgn).Add(name);
|
||||
if (xnde.Atrs_bgn() > Xop_tblw_wkr.Atrs_ignore_check) Xnde_atrs(tag_id, hctx, src, xnde.Atrs_bgn(), xnde.Atrs_end(), xnde.Atrs_ary(), bfr);
|
||||
bfr.Add_byte(Tag__end);
|
||||
bfr.Add_byte(Byte_ascii.Angle_end);
|
||||
Xnde_subs_escape(ctx, hctx, bfr, src, xnde, false, true);
|
||||
bfr.Add(Tag__end_bgn).Add(name).Add_byte(Tag__end);
|
||||
bfr.Add(Tag__end_bgn).Add(name).Add_byte(Byte_ascii.Angle_end);
|
||||
break;
|
||||
}
|
||||
case Xop_xnde_tag_.Tid_li: {
|
||||
@@ -360,13 +285,13 @@ public class Xoh_html_wtr {
|
||||
int bfr_len = bfr.Len();
|
||||
if (bfr_len > 0 && bfr.Bfr()[bfr_len - 1] != Byte_ascii.Nl) bfr.Add_byte_nl(); // NOTE: always add nl before li else some lists will merge and force long horizontal bar; EX:w:Music
|
||||
if (xnde.Tag_visible()) {
|
||||
bfr.Add_byte(Tag__bgn).Add(name);
|
||||
bfr.Add_byte(Byte_ascii.Angle_bgn).Add(name);
|
||||
if (xnde.Atrs_bgn() > Xop_tblw_wkr.Atrs_ignore_check) Xnde_atrs(tag_id, hctx, src, xnde.Atrs_bgn(), xnde.Atrs_end(), xnde.Atrs_ary(), bfr);
|
||||
bfr.Add_byte(Tag__end);
|
||||
bfr.Add_byte(Byte_ascii.Angle_end);
|
||||
}
|
||||
Xnde_subs(ctx, hctx, bfr, src, xnde);
|
||||
if (xnde.Tag_visible())
|
||||
bfr.Add(Tag__end_bgn).Add(name).Add_byte(Tag__end); // NOTE: inline is never written as <b/>; will be written as <b></b>; SEE: NOTE_1
|
||||
bfr.Add(Tag__end_bgn).Add(name).Add_byte(Byte_ascii.Angle_end); // NOTE: inline is never written as <b/>; will be written as <b></b>; SEE: NOTE_1
|
||||
break;
|
||||
}
|
||||
case Xop_xnde_tag_.Tid_timeline: {
|
||||
@@ -462,20 +387,20 @@ public class Xoh_html_wtr {
|
||||
if (ws_bfr.Len() > 0) bfr.Add_bfr_and_clear(ws_bfr); // dump ws_bfr to real bfr
|
||||
if (at_bgn) { // 1st non-ws tkn; add open tag; <b>
|
||||
at_bgn = false;
|
||||
bfr.Add_byte(Tag__bgn).Add(name);
|
||||
bfr.Add_byte(Byte_ascii.Angle_bgn).Add(name);
|
||||
if (xnde.Atrs_bgn() > Xop_tblw_wkr.Atrs_ignore_check) Xnde_atrs(tag_id, hctx, src, xnde.Atrs_bgn(), xnde.Atrs_end(), xnde.Atrs_ary(), bfr);
|
||||
bfr.Add_byte(Tag__end);
|
||||
bfr.Add_byte(Byte_ascii.Angle_end);
|
||||
}
|
||||
Write_tkn(bfr, ctx, hctx, src, xnde, i, sub); // NOTE: never escape; <p>, <table>, <center> etc may have nested nodes
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (at_bgn) { // occurs when xnde is empty; EX: <b></b>
|
||||
bfr.Add_byte(Tag__bgn).Add(name);
|
||||
bfr.Add_byte(Byte_ascii.Angle_bgn).Add(name);
|
||||
if (xnde.Atrs_bgn() > Xop_tblw_wkr.Atrs_ignore_check) Xnde_atrs(tag_id, hctx, src, xnde.Atrs_bgn(), xnde.Atrs_end(), xnde.Atrs_ary(), bfr);
|
||||
bfr.Add_byte(Tag__end);
|
||||
bfr.Add_byte(Byte_ascii.Angle_end);
|
||||
}
|
||||
bfr.Add(Tag__end_bgn).Add(name).Add_byte(Tag__end); // NOTE: inline is never written as <b/>; will be written as <b></b>; SEE: NOTE_1
|
||||
bfr.Add(Tag__end_bgn).Add(name).Add_byte(Byte_ascii.Angle_end); // NOTE: inline is never written as <b/>; will be written as <b></b>; SEE: NOTE_1
|
||||
if (ws_bfr.Len() > 0) bfr.Add_bfr_and_clear(ws_bfr); // dump any leftover ws to bfr; handles "<b>c </b>" -> "<b>c</b> "
|
||||
ws_bfr.Mkr_rls();
|
||||
}
|
||||
@@ -569,7 +494,7 @@ public class Xoh_html_wtr {
|
||||
bfr.Add(bgn);
|
||||
int atrs_bgn = tkn.Atrs_bgn();
|
||||
if (atrs_bgn != -1) Xnde_atrs(tkn.Tblw_tid(), hctx, src, atrs_bgn, tkn.Atrs_end(), tkn.Atrs_ary(), bfr); //bfr.Add_byte(Byte_ascii.Space).Add_mid(src, atrs_bgn, tkn.Atrs_end());
|
||||
bfr.Add_byte(Tag__end);
|
||||
bfr.Add_byte(Byte_ascii.Angle_end);
|
||||
++indent_level;
|
||||
}
|
||||
int subs_len = tkn.Subs_len();
|
||||
@@ -588,7 +513,7 @@ public class Xoh_html_wtr {
|
||||
}
|
||||
}
|
||||
public static final byte[] Tag__end_quote = Bry_.new_a7("\">"), Tag__end_bgn = Bry_.new_a7("</")
|
||||
, Tag_hdr_bgn = Bry_.new_a7("<h"), Tag_hdr_end = Bry_.new_a7("</h"), Tag_hr = Bry_.new_a7("<hr/>"), Tag_br = Bry_.new_a7("<br/>")
|
||||
, Tag_hr = Bry_.new_a7("<hr/>"), Tag_br = Bry_.new_a7("<br/>")
|
||||
, Tag_list_grp_ul_bgn = Bry_.new_a7("<ul>"), Tag_list_grp_ul_end = Bry_.new_a7("</ul>")
|
||||
, Tag_list_grp_ol_bgn = Bry_.new_a7("<ol>"), Tag_list_grp_ol_end = Bry_.new_a7("</ol>")
|
||||
, Tag_list_itm_li_bgn = Bry_.new_a7("<li>"), Tag_list_itm_li_end = Bry_.new_a7("</li>")
|
||||
@@ -602,11 +527,7 @@ public class Xoh_html_wtr {
|
||||
, Tag_tblw_th_bgn = Bry_.new_a7("<th>"), Tag_tblw_th_bgn_atr = Bry_.new_a7("<th"), Tag_tblw_th_end = Bry_.new_a7("</th>")
|
||||
, Tag_tblw_tc_bgn = Bry_.new_a7("<caption>"), Tag_tblw_tc_bgn_atr = Bry_.new_a7("<caption"), Tag_tblw_tc_end = Bry_.new_a7("</caption>")
|
||||
, Ary_escape_bgn = Bry_.new_a7("<"), Ary_escape_end = Bry_.new_a7(">"), Ary_escape_end_bgn = Bry_.new_a7("</")
|
||||
, Tag_para_bgn = Bry_.new_a7("<p>"), Tag_para_end = Bry_.new_a7("</p>"), Tag_para_mid = Bry_.new_a7("</p>\n\n<p>")
|
||||
, Tag_pre_bgn = Bry_.new_a7("<pre>"), Tag_pre_end = Bry_.new_a7("</pre>")
|
||||
;
|
||||
private static final byte[] Tag_hdr__div_wrapper_bgn = Bry_.new_a7("<div>\n"), Tag_hdr__div_wrapper_end = Bry_.new_a7("</div>\n");
|
||||
public static final byte Tag__bgn = Byte_ascii.Lt, Tag__end = Byte_ascii.Gt;
|
||||
public static final byte Dir_spr_http = Byte_ascii.Slash;
|
||||
private int indent_level = 0;
|
||||
public static final int Sub_idx_null = -1; // nonsense placeholder
|
||||
24
400_xowa/src/gplx/xowa/htmls/core/htmls/Xoh_html_wtr_.java
Normal file
24
400_xowa/src/gplx/xowa/htmls/core/htmls/Xoh_html_wtr_.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
public class Xoh_html_wtr_ {
|
||||
public static void Para__assert_tag_starts_on_nl(Bry_bfr bfr, int src_bgn) {
|
||||
if (!bfr.Match_end_byt_nl_or_bos()) bfr.Add_byte_nl();
|
||||
if (src_bgn != 0) bfr.Add_byte_nl();
|
||||
}
|
||||
}
|
||||
@@ -15,11 +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; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.htmls.core.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
public class Xoh_html_wtr_cfg {
|
||||
public boolean Toc__show() {return toc__show;} public Xoh_html_wtr_cfg Toc__show_(boolean v) {toc__show = v; return this;} private boolean toc__show;
|
||||
public boolean Lnki__id() {return lnki__id;} public Xoh_html_wtr_cfg Lnki__id_y_() {lnki__id = Bool_.Y; return this;} private boolean lnki__id;
|
||||
public boolean Lnki__id() {return lnki__id;} public Xoh_html_wtr_cfg Lnki__id_(boolean v) {lnki__id = v; return this;} private boolean lnki__id;
|
||||
public boolean Lnki__title() {return lnki__title;} public Xoh_html_wtr_cfg Lnki__title_(boolean v) {lnki__title = v; return this;} private boolean lnki__title;
|
||||
public boolean Lnki__visited() {return lnki__visited;} public Xoh_html_wtr_cfg Lnki_visited_y_() {lnki__visited = true; return this;} private boolean lnki__visited;
|
||||
public boolean Hdr__div_wrapper() {return hdr__div_wrapper;} public Xoh_html_wtr_cfg Hdr__div_wrapper_(boolean v) {hdr__div_wrapper = v; return this;} private boolean hdr__div_wrapper;
|
||||
}
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.htmls.core.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.core.btries.*; import gplx.langs.htmls.*;
|
||||
import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.xndes.*;
|
||||
public class Xoh_html_wtr_escaper {
|
||||
@@ -34,7 +34,7 @@ public class Xoh_html_wtr_escaper {
|
||||
int nowiki_name_len = nowiki_name.length;
|
||||
if (Bry_.Eq(src, i + 1, i + 1 + nowiki_name_len, nowiki_name)) { // <nowiki found;
|
||||
int end_gt = Escape_nowiki_skip(bfr, src, i, end, nowiki_name, nowiki_name_len);
|
||||
if (end_gt != Bry_.NotFound) {
|
||||
if (end_gt != Bry_find_.Not_found) {
|
||||
i = end_gt;
|
||||
continue;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class Xoh_html_wtr_escaper {
|
||||
switch (b) {
|
||||
case Byte_ascii.Gt:
|
||||
if (tag_is_bgn) {bgn_gt = i; tag_is_bgn = false;}
|
||||
else return Bry_.NotFound; // <nowiki>> found
|
||||
else return Bry_find_.Not_found; // <nowiki>> found
|
||||
break;
|
||||
case Byte_ascii.Lt:
|
||||
if ( tag_is_bgn // <nowiki < found
|
||||
@@ -105,20 +105,20 @@ public class Xoh_html_wtr_escaper {
|
||||
|| src[i + 1] != Byte_ascii.Slash // /
|
||||
|| !Bry_.Eq(src, i + 2, i + 2 + nowiki_name_len, nowiki_name) // nowiki
|
||||
|| src[i + 2 + nowiki_name_len] != Byte_ascii.Gt // >
|
||||
) return Bry_.NotFound;
|
||||
) return Bry_find_.Not_found;
|
||||
end_lt = i;
|
||||
end_gt = i + 2 + nowiki_name_len;
|
||||
i = end;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (end_gt == -1) return Bry_.NotFound; // ">" of </nowiki> not found
|
||||
if (end_gt == -1) return Bry_find_.Not_found; // ">" of </nowiki> not found
|
||||
bfr.Add_mid(src, bgn_gt + 1, end_lt);
|
||||
return end_gt;
|
||||
}
|
||||
catch (Exception e) {
|
||||
Xoa_app_.Usr_dlg().Warn_many("", "", "unknown error in escape.nowiki: ~{0} ~{1}", String_.new_u8(src, bgn, end), Err_.Message_gplx_full(e));
|
||||
return Bry_.NotFound;
|
||||
return Bry_find_.Not_found;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.htmls.core.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import org.junit.*;
|
||||
public class Xoh_html_wtr_tst {
|
||||
private Xop_fxt fxt = new Xop_fxt();
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.htmls.core.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
public class Xoh_wtr_ctx {
|
||||
Xoh_wtr_ctx(byte mode) {this.mode = mode;} private byte mode;
|
||||
public boolean Mode_is_alt() {return mode == Mode_alt;}
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.tidy; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
package gplx.xowa.htmls.core.htmls.tidy; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.langs.htmls.*;
|
||||
import gplx.xowa.apps.fsys.*;
|
||||
public class Xoh_tidy_mgr implements GfoInvkAble {
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.tidy; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
package gplx.xowa.htmls.core.htmls.tidy; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import org.junit.*;
|
||||
public class Xoh_tidy_mgr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xoh_tidy_mgr_fxt fxt = new Xoh_tidy_mgr_fxt();
|
||||
@@ -77,12 +77,12 @@ class Xoh_tidy_mgr_fxt {
|
||||
bfr.Clear();
|
||||
}
|
||||
public void Test_wrap(String val, String expd) {
|
||||
bfr.Add_str(val);
|
||||
bfr.Add_str_u8(val);
|
||||
Xoh_tidy_mgr.Tidy_wrap(bfr);
|
||||
Tfds.Eq(expd, bfr.To_str_and_clear());
|
||||
}
|
||||
public void Test_unwrap(String val, boolean expd_pass, String expd) {
|
||||
bfr.Add_str(val);
|
||||
bfr.Add_str_u8(val);
|
||||
boolean actl_pass = Xoh_tidy_mgr.Tidy_unwrap(bfr);
|
||||
if (actl_pass != expd_pass) Tfds.Fail("expd={0} actl={1}", expd_pass, actl_pass);
|
||||
else if (expd_pass) {
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.tidy; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
package gplx.xowa.htmls.core.htmls.tidy; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
public interface Xoh_tidy_wkr {
|
||||
byte Tid();
|
||||
void Exec_tidy(Xoae_page page, Bry_bfr bfr);
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.tidy; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
package gplx.xowa.htmls.core.htmls.tidy; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
public class Xoh_tidy_wkr_ {
|
||||
public static final byte Tid_null = 0, Tid_tidy = 1, Tid_jtidy = 2;
|
||||
public static final String Key_null = "null", Key_tidy = "tidy", Key_jtidy = "jtidy";
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.tidy; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
package gplx.xowa.htmls.core.htmls.tidy; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.tidy; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
package gplx.xowa.htmls.core.htmls.tidy; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import org.w3c.tidy.Tidy;
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.tidy; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
package gplx.xowa.htmls.core.htmls.tidy; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
public class Xoh_tidy_wkr_tidy extends ProcessAdp implements Xoh_tidy_wkr { private Xoae_app app; private Io_url tidy_source, tidy_target;
|
||||
public byte Tid() {return Xoh_tidy_wkr_.Tid_tidy;}
|
||||
public void Init_by_app(Xoae_app app) {
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.wtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
package gplx.xowa.htmls.core.htmls.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.langs.htmls.*;
|
||||
public class Xoh_anchor_kv_bldr {
|
||||
private byte[] base_url; private boolean has_qarg;
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.wtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
package gplx.xowa.htmls.core.htmls.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
public class Xoh_img_path {
|
||||
public static final byte[]
|
||||
Img_cancel = Bry_.new_a7("app.general/cancel.png") // 32,32
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.wtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
package gplx.xowa.htmls.core.htmls.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.hrefs.*;
|
||||
public class Xoh_lnki_bldr {
|
||||
private final Xoa_app app; private final Xoh_href_wtr href_wtr; private final byte[] img_root_dir;
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.wtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
package gplx.xowa.htmls.core.htmls.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.hrefs.*;
|
||||
public class Xoh_lnki_wtr_utl {
|
||||
private final Xoa_app app; private final Xow_wiki wiki; private final Xoh_href_wtr href_wtr; private final Bry_bfr tmp_bfr = Bry_bfr.new_(255);
|
||||
70
400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_dict_.java
Normal file
70
400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_dict_.java
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*;
|
||||
import gplx.xowa.htmls.core.wkrs.spaces.*; 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.escapes.*;
|
||||
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_ints(27); // SERIALIZED
|
||||
private static final byte Base85_ascii = 33;
|
||||
public static final byte // SERIALIZED
|
||||
Tid__space = 0 + Base85_ascii
|
||||
, Tid__hdr = 1 + Base85_ascii
|
||||
, Tid__lnke = 2 + Base85_ascii
|
||||
, Tid__lnki = 3 + Base85_ascii
|
||||
, Tid__escape = 84 + Base85_ascii
|
||||
;
|
||||
public static final byte[]
|
||||
Bry__space = Bry_.new_ints(Escape, Tid__space)
|
||||
, Bry__hdr = Bry_.new_ints(Escape, Tid__hdr)
|
||||
, Bry__lnke = Bry_.new_ints(Escape, Tid__lnke)
|
||||
, Bry__lnki = Bry_.new_ints(Escape, Tid__lnki)
|
||||
, Bry__escape = Bry_.new_ints(Escape, Tid__escape)
|
||||
;
|
||||
public static final String
|
||||
Key__space = "space"
|
||||
, Key__hdr = "hdr"
|
||||
, Key__lnke = "lnke"
|
||||
, Key__lnki = "lnki"
|
||||
, Key__escape = "escape"
|
||||
;
|
||||
public static Xoh_hzip_wkr To_wkr(byte tid) {
|
||||
switch (tid) {
|
||||
case Tid__space: return Wkr__space;
|
||||
case Tid__hdr: return Wkr__hdr;
|
||||
case Tid__lnke: return Wkr__lnke;
|
||||
case Tid__lnki: return Wkr__lnki;
|
||||
case Tid__escape: return Wkr__escape;
|
||||
default: throw Err_.new_unhandled(tid);
|
||||
}
|
||||
}
|
||||
public static final Btrie_slim_mgr Trie = Btrie_slim_mgr.cs()
|
||||
.Add_bry_byte(Xoh_html_dict_.Hook__space , Xoh_hzip_dict_.Tid__space) // 4 spaces b/c escape code will be 3 bytes
|
||||
.Add_bry_byte(Xoh_html_dict_.Type__hdr , Xoh_hzip_dict_.Tid__hdr)
|
||||
.Add_bry_byte(Xoh_html_dict_.Hook__lnke , Xoh_hzip_dict_.Tid__lnke)
|
||||
.Add_bry_byte(Xoh_html_dict_.Hook__lnki , Xoh_hzip_dict_.Tid__lnki)
|
||||
.Add_bry_byte(Escape_bry , Xoh_hzip_dict_.Tid__escape)
|
||||
;
|
||||
public static final Xoh_hzip_wkr
|
||||
Wkr__space = new Xoh_space_hzip()
|
||||
, Wkr__hdr = new Xoh_hdr_hzip()
|
||||
, Wkr__lnke = new Xoh_lnke_hzip()
|
||||
, Wkr__lnki = new Xoh_lnki_hzip()
|
||||
, Wkr__escape = new Xoh_escape_hzip()
|
||||
;
|
||||
}
|
||||
62
400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_int_.java
Normal file
62
400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_int_.java
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.core.primitives.*; import gplx.core.encoders.*;
|
||||
public class Xoh_hzip_int_ {
|
||||
public static void Encode(int reqd, Bry_bfr bfr, int val) {
|
||||
int bfr_len = bfr.Len();
|
||||
int len_in_base85 = Base85_.Bry_len(val);
|
||||
boolean abrv = val < Base85_.Pow85[reqd];
|
||||
int adj = abrv ? 0 : 1;
|
||||
int actl_len = len_in_base85 + adj;
|
||||
if (actl_len < reqd) actl_len = reqd;
|
||||
bfr.Add_byte_repeat(Byte_ascii.Bang, actl_len); // fill with 0s; this asserts that there underlying array will be large enough for following write
|
||||
byte[] bfr_bry = bfr.Bfr(); // NOTE: set bry reference here b/c Add_byte_repeat may create a new one
|
||||
Base85_.Set_bry(val, bfr_bry, bfr_len + adj, reqd); // calc base85 val for val; EX: 7224 -> "uu"
|
||||
if (!abrv) {
|
||||
byte base85_byte = Base85_len__2;
|
||||
switch (len_in_base85) {
|
||||
case 3: base85_byte = Base85_len__3; break;
|
||||
case 4: base85_byte = Base85_len__4; break;
|
||||
case 5: base85_byte = Base85_len__5; break;
|
||||
}
|
||||
bfr_bry[bfr_len] = base85_byte;
|
||||
}
|
||||
}
|
||||
public static int Decode(int reqd, byte[] src, int src_len, int src_bgn, Int_obj_ref pos_ref) {
|
||||
byte b0 = src[src_bgn];
|
||||
int base85_bgn = src_bgn + 1;
|
||||
int len_in_base85 = 1; // default to 1
|
||||
switch (b0) {
|
||||
case Base85_len__2: len_in_base85 = 2; break;
|
||||
case Base85_len__3: len_in_base85 = 3; break;
|
||||
case Base85_len__4: len_in_base85 = 4; break;
|
||||
case Base85_len__5: len_in_base85 = 5; break;
|
||||
default: --base85_bgn; break;
|
||||
}
|
||||
if (len_in_base85 < reqd) len_in_base85 = reqd;
|
||||
int base85_end = base85_bgn + len_in_base85;
|
||||
pos_ref.Val_(base85_end);
|
||||
return Base85_.To_int_by_bry(src, base85_bgn, base85_end - 1);
|
||||
}
|
||||
private static final byte
|
||||
Base85_len__2 = Byte_ascii.Curly_bgn
|
||||
, Base85_len__3 = Byte_ascii.Pipe
|
||||
, Base85_len__4 = Byte_ascii.Curly_end
|
||||
, Base85_len__5 = Byte_ascii.Tilde;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
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 org.junit.*;
|
||||
public class Xoh_hzip_int__tst {
|
||||
private final Xoh_hzip_int__fxt fxt = new Xoh_hzip_int__fxt();
|
||||
@Test public void Reqd__1() {
|
||||
fxt.Test__encode(1, 0, "!");
|
||||
fxt.Test__encode(1, 84, "u");
|
||||
fxt.Test__encode(1, 85, "{\"!");
|
||||
fxt.Test__encode(1, 7225, "|\"!!");
|
||||
fxt.Test__encode(1, 614125, "}\"!!!");
|
||||
fxt.Test__encode(1, 52200625, "~\"!!!!");
|
||||
}
|
||||
@Test public void Reqd__2() {
|
||||
fxt.Test__encode(2, 0, "!!");
|
||||
fxt.Test__encode(2, 84, "!u");
|
||||
fxt.Test__encode(2, 85, "\"!");
|
||||
fxt.Test__encode(2, 7225, "|\"!!");
|
||||
fxt.Test__encode(2, 614125, "}\"!!!");
|
||||
fxt.Test__encode(2, 52200625, "~\"!!!!");
|
||||
}
|
||||
}
|
||||
class Xoh_hzip_int__fxt {
|
||||
private final Bry_bfr bfr = Bry_bfr.new_();
|
||||
private final gplx.core.primitives.Int_obj_ref count_ref = gplx.core.primitives.Int_obj_ref.neg1_();
|
||||
public void Test__encode(int reqd, int val, String expd) {
|
||||
Xoh_hzip_int_.Encode(reqd, bfr, val);
|
||||
byte[] actl = bfr.To_bry_and_clear();
|
||||
Tfds.Eq(expd, String_.new_u8(actl));
|
||||
Tfds.Eq(val, Xoh_hzip_int_.Decode(reqd, actl, actl.length, 0, count_ref));
|
||||
}
|
||||
}
|
||||
76
400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_mgr.java
Normal file
76
400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_mgr.java
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
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.core.primitives.*; import gplx.core.brys.*; import gplx.core.btries.*; import gplx.xowa.wikis.ttls.*;
|
||||
import gplx.xowa.htmls.core.hzips.stats.*;
|
||||
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.spaces.*; import gplx.xowa.htmls.core.wkrs.escapes.*;
|
||||
public class Xoh_hzip_mgr {
|
||||
private final Btrie_slim_mgr trie = Xoh_hzip_dict_.Trie;
|
||||
private final Bry_parser parser = new Bry_parser();
|
||||
public void Encode(Bry_bfr bfr, Xow_ttl_parser ttl_parser, byte[] page_url, byte[] src, Hzip_stat_itm stat_itm) {
|
||||
bfr.Clear(); stat_itm.Clear();
|
||||
((Xoh_lnki_hzip)Xoh_hzip_dict_.To_wkr(Xoh_hzip_dict_.Tid__lnki)).Ttl_parser_(ttl_parser);
|
||||
int pos = 0, add_bgn = -1; int src_len = src.length;
|
||||
parser.Init_src(page_url, src, src_len, 0);
|
||||
while (pos < src_len) {
|
||||
Object o = trie.Match_bgn_w_byte(src[pos], src, pos, src_len);
|
||||
if (o == null) {
|
||||
if (add_bgn == -1) add_bgn = pos;
|
||||
++pos;
|
||||
}
|
||||
else {
|
||||
if (add_bgn != -1) {bfr.Add_mid(src, add_bgn, pos); add_bgn = -1;}
|
||||
try {
|
||||
Xoh_hzip_wkr wkr = Xoh_hzip_dict_.To_wkr(((Byte_obj_val)o).Val());
|
||||
parser.Init_hook(wkr.Key(), pos, trie.Match_pos());
|
||||
wkr.Encode(bfr, stat_itm, parser, src, pos);
|
||||
pos = parser.Pos();
|
||||
} catch (Exception e) {
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", Err_.Message_gplx_log(e));
|
||||
pos = trie.Match_pos();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (add_bgn != -1) bfr.Add_mid(src, add_bgn, src_len);
|
||||
}
|
||||
public byte[] Decode(Bry_bfr bfr, Xow_ttl_parser ttl_parser, byte[] page_url, byte[] src) {
|
||||
bfr.Clear();
|
||||
int pos = 0, add_bgn = -1; int src_len = src.length;
|
||||
parser.Init_src(page_url, src, src_len, 0);
|
||||
while (pos < src_len) {
|
||||
if (src[pos] == Xoh_hzip_dict_.Escape) {
|
||||
if (add_bgn != -1) {bfr.Add_mid(src, add_bgn, pos); add_bgn = -1;}
|
||||
try {
|
||||
Xoh_hzip_wkr wkr = Xoh_hzip_dict_.To_wkr(src[pos + 1]);
|
||||
parser.Init_hook(wkr.Key(), pos, pos + 2);
|
||||
wkr.Decode(bfr, parser, src, pos);
|
||||
pos = parser.Pos();
|
||||
} catch (Exception e) {
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", Err_.Message_gplx_log(e));
|
||||
pos += 2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (add_bgn == -1) add_bgn = pos;
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
if (add_bgn != -1) bfr.Add_mid(src, add_bgn, src_len);
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
}
|
||||
@@ -15,16 +15,18 @@ 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.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
class Xow_hzip_mgr_fxt {
|
||||
private Bry_bfr bfr = Bry_bfr.reset_(Io_mgr.Len_mb); private Xow_hzip_mgr hzip_mgr; private Xowe_wiki wiki;
|
||||
private Xodump_stats_itm stats = new Xodump_stats_itm(); private final Ordered_hash redlink_uids = Ordered_hash_.New();
|
||||
import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.hzips.stats.*;
|
||||
public class Xoh_hzip_mgr_fxt {
|
||||
private final Bry_bfr bfr = Bry_bfr.reset_(Io_mgr.Len_mb); private Xoh_hzip_mgr hzip_mgr; private Xowe_wiki wiki;
|
||||
private Hzip_stat_itm stat_itm = new Hzip_stat_itm();
|
||||
public void Clear() {
|
||||
if (hzip_mgr == null) {
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
wiki = Xoa_app_fxt.wiki_tst_(app);
|
||||
hzip_mgr = new Xow_hzip_mgr(Gfo_usr_dlg_.Instance, wiki);
|
||||
hzip_mgr = wiki.Html__hdump_mgr().Hzip_mgr().Hzip_mgr();
|
||||
wiki.Init_by_wiki();
|
||||
}
|
||||
}
|
||||
public void Init_xwiki(String alias, String domain) {
|
||||
@@ -32,29 +34,38 @@ class Xow_hzip_mgr_fxt {
|
||||
wiki.Xwiki_mgr().Add_by_atrs(alias, domain);
|
||||
wiki.Appe().Usere().Wiki().Xwiki_mgr().Add_by_atrs(domain, domain);
|
||||
}
|
||||
public byte[] Make_int(int v) {return Xow_hzip_int_.Save_bin_int_abrv(v);}
|
||||
public void Test_save(byte[][] expd_brys, String html) {Test_save(html, expd_brys);}
|
||||
public void Test_save(String html, byte[]... expd_brys) {
|
||||
byte[] expd = Bry_.Add(expd_brys);
|
||||
hzip_mgr.Write(bfr, stats, Bry_.Empty, Bry_.new_u8(html));
|
||||
hzip_mgr.Encode(bfr, wiki, Bry_.Empty, Bry_.new_u8(html), stat_itm);
|
||||
Tfds.Eq_ary(expd, bfr.To_bry_and_clear());
|
||||
}
|
||||
public void Test_load(byte[][] src_brys, String expd) {
|
||||
byte[] src = Bry_.Add(src_brys);
|
||||
src = hzip_mgr.Parse(bfr, Bry_.Empty, src, redlink_uids);
|
||||
Tfds.Eq(expd, String_.new_u8(src));
|
||||
private final Xoh_page hpg = new Xoh_page();
|
||||
public void Test_swap(String src, String expd) {
|
||||
Gfo_usr_dlg_.Instance = Gfo_usr_dlg_.Test_console();
|
||||
byte[] actl = wiki.Html__hdump_mgr().Load_mgr().Make_mgr().Parse(hpg, Bry_.new_u8(src));
|
||||
Gfo_usr_dlg_.Instance = Gfo_usr_dlg_.Noop;
|
||||
Tfds.Eq_str_lines(expd, String_.new_u8(actl));
|
||||
}
|
||||
public void Test_html(String html, String expd) {
|
||||
public void Test_load(byte[][] src_brys, String expd) {Test_load(Bry_.Add(src_brys), expd);}
|
||||
public void Test_load(String src, String expd) {Test_load(Bry_.new_u8(src), expd);}
|
||||
public void Test_load(byte[] src, String expd) {
|
||||
byte[] actl = hzip_mgr.Decode(bfr, wiki, Bry_.Empty, src);
|
||||
Tfds.Eq(expd, String_.new_u8(actl));
|
||||
}
|
||||
public void Test_html(String wtxt, String expd) {
|
||||
Xop_ctx ctx = wiki.Parser_mgr().Ctx(); Xop_parser parser = wiki.Parser_mgr().Main(); Xop_tkn_mkr tkn_mkr = ctx.Tkn_mkr();
|
||||
ctx.Para().Enabled_n_();
|
||||
ctx.Cur_page().Redlink_lnki_list().Clear();
|
||||
byte[] html_bry = Bry_.new_u8(html);
|
||||
byte[] html_bry = Bry_.new_u8(wtxt);
|
||||
Xop_root_tkn root = ctx.Tkn_mkr().Root(html_bry);
|
||||
parser.Parse_page_all_clear(root, ctx, tkn_mkr, html_bry);
|
||||
Xoh_wtr_ctx hctx = Xoh_wtr_ctx.Hdump;
|
||||
Xoh_html_wtr html_wtr = wiki.Html_mgr().Html_wtr();
|
||||
html_wtr.Cfg().Toc__show_(Bool_.Y); // needed for hdr to show <span class='mw-headline' id='A'>
|
||||
html_wtr.Cfg().Lnki__title_(Bool_.N);
|
||||
html_wtr.Cfg().Lnki__id_(Bool_.N);
|
||||
html_wtr.Write_all(bfr, ctx, hctx, html_bry, root);
|
||||
Tfds.Eq(expd, bfr.To_str_and_clear());
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
25
400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_wkr.java
Normal file
25
400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_wkr.java
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.core.brys.*;
|
||||
import gplx.xowa.htmls.core.hzips.stats.*;
|
||||
public interface Xoh_hzip_wkr {
|
||||
String Key();
|
||||
void Encode(Bry_bfr bfr, Hzip_stat_itm stat_itm, Bry_parser parser, byte[] src, int hook_bgn);
|
||||
int Decode(Bry_bfr bfr, Bry_parser parser, byte[] src, int hook_bgn);
|
||||
}
|
||||
74
400_xowa/src/gplx/xowa/htmls/core/hzips/Xow_hzip_mgr.java
Normal file
74
400_xowa/src/gplx/xowa/htmls/core/hzips/Xow_hzip_mgr.java
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
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.core.ios.*; import gplx.xowa.htmls.core.hzips.stats.*;
|
||||
public class Xow_hzip_mgr {
|
||||
private final Xow_wiki wiki; private final Io_stream_zip_mgr zip_mgr;
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.new_(255);
|
||||
private boolean default_hzip_enabled; private byte default_zip_tid, body_flag;
|
||||
public Xow_hzip_mgr(Xow_wiki wiki) {
|
||||
this.wiki = wiki;
|
||||
this.zip_mgr = new Io_stream_zip_mgr();
|
||||
}
|
||||
public Xoh_hzip_mgr Hzip_mgr() {return hzip_mgr;} private final Xoh_hzip_mgr hzip_mgr = new Xoh_hzip_mgr();
|
||||
public Hzip_stat_itm Stat_itm() {return stat_itm;} private final Hzip_stat_itm stat_itm = new Hzip_stat_itm();
|
||||
public byte Body_flag() {return body_flag;}
|
||||
public void Init_by_db(Xow_wiki wiki) {
|
||||
this.Init_by_atrs(wiki.Data__core_mgr().Props().Zip_tid_html(), wiki.Data__core_mgr().Props().Hzip_enabled());
|
||||
}
|
||||
public void Init_by_atrs(byte default_zip_tid, boolean default_hzip_enabled) {
|
||||
this.default_zip_tid = default_zip_tid;
|
||||
this.default_hzip_enabled = default_hzip_enabled;
|
||||
this.body_flag = default_hzip_enabled ? (byte)(default_zip_tid + Zip_tid_cutoff) : default_zip_tid;
|
||||
}
|
||||
public byte[] Write(byte[] page_url, byte storage_flag, byte[] src) {
|
||||
byte zip_tid = default_zip_tid;
|
||||
boolean hzip_enabled = default_hzip_enabled;
|
||||
if (storage_flag != Byte_.Max_value_127) {
|
||||
zip_tid = storage_flag;
|
||||
if (storage_flag > Zip_tid_cutoff) {
|
||||
hzip_enabled = Bool_.Y;
|
||||
zip_tid -= Zip_tid_cutoff;
|
||||
}
|
||||
}
|
||||
if (hzip_enabled) {
|
||||
hzip_mgr.Encode(tmp_bfr, wiki, page_url, src, stat_itm);
|
||||
src = tmp_bfr.To_bry_and_rls();
|
||||
}
|
||||
if (zip_tid != Io_stream_.Tid_raw)
|
||||
src = zip_mgr.Zip(zip_tid, src);
|
||||
return src;
|
||||
}
|
||||
public byte[] Parse(byte[] page_url, byte storage_flag, byte[] src) {
|
||||
byte zip_tid = default_zip_tid;
|
||||
boolean hzip_enabled = default_hzip_enabled;
|
||||
if (storage_flag != Byte_.Max_value_127) {
|
||||
zip_tid = storage_flag;
|
||||
if (storage_flag > Zip_tid_cutoff) {
|
||||
hzip_enabled = Bool_.Y;
|
||||
zip_tid -= Zip_tid_cutoff;
|
||||
}
|
||||
}
|
||||
if (zip_tid != Io_stream_.Tid_raw)
|
||||
src = zip_mgr.Unzip(default_zip_tid, src);
|
||||
if (hzip_enabled)
|
||||
src = hzip_mgr.Decode(tmp_bfr, wiki, page_url, src);
|
||||
return src;
|
||||
}
|
||||
private static final byte Zip_tid_cutoff = 7;
|
||||
}
|
||||
@@ -15,12 +15,14 @@ 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.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
public class Xodump_stats_itm {
|
||||
package gplx.xowa.htmls.core.hzips.stats; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Hzip_stat_itm {
|
||||
public void Clear() {
|
||||
a_rhs = lnki_text_n = lnki_text_y = lnke_txt = lnke_brk_text_n = lnke_brk_text_y = 0;
|
||||
hdr_1 = hdr_2 = hdr_3 = hdr_4 = hdr_5 = hdr_6 = 0;
|
||||
img_full = 0;
|
||||
space = 0;
|
||||
escape = 0;
|
||||
}
|
||||
public int A_rhs() {return a_rhs;} public void A_rhs_add() {++a_rhs;} private int a_rhs;
|
||||
public int Lnki_text_n() {return lnki_text_n;} public void Lnki_text_n_add() {++lnki_text_n;} private int lnki_text_n;
|
||||
@@ -35,6 +37,8 @@ public class Xodump_stats_itm {
|
||||
public int Hdr_4() {return hdr_4;} private int hdr_4;
|
||||
public int Hdr_5() {return hdr_5;} private int hdr_5;
|
||||
public int Hdr_6() {return hdr_6;} private int hdr_6;
|
||||
public int Space() {return space;} public void Space_add(int v) {space += v;} private int space;
|
||||
public int Escape() {return escape;} public void Escape_add_one() {++escape;} private int escape;
|
||||
public void Hdr_add(byte hdr_num) {
|
||||
switch (hdr_num) {
|
||||
case 1: ++hdr_1; break;
|
||||
@@ -15,10 +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.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.dbs.*; import gplx.dbs.engines.sqlite.*; import gplx.xowa.htmls.hdumps.core.*; import gplx.xowa.htmls.hzips.*; import gplx.xowa.htmls.hdumps.pages.*;
|
||||
import gplx.xowa.guis.*;
|
||||
public class Xodump_stats_tbl implements RlsAble {
|
||||
package gplx.xowa.htmls.core.hzips.stats; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.dbs.*; import gplx.dbs.engines.sqlite.*; import gplx.xowa.htmls.core.makes.imgs.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.wikis.pages.*;
|
||||
public class Hzip_stat_tbl implements RlsAble {
|
||||
private static final String tbl_name = "hdump_stats"; private static final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private static final String
|
||||
fld_page_id = flds.Add_int_pkey("page_id"), fld_wtxt_len = flds.Add_int("wtxt_len"), fld_row_orig_len = flds.Add_int("row_orig_len"), fld_row_zip_len = flds.Add_int("row_zip_len")
|
||||
@@ -30,7 +30,7 @@ public class Xodump_stats_tbl implements RlsAble {
|
||||
, fld_img_full = flds.Add_int("img_full")
|
||||
;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert;
|
||||
public Xodump_stats_tbl(Db_conn conn) {
|
||||
public Hzip_stat_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.Create_tbl();
|
||||
conn.Stmt_delete(tbl_name).Exec_delete(); // always zap table
|
||||
@@ -40,7 +40,7 @@ public class Xodump_stats_tbl implements RlsAble {
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
}
|
||||
public void Insert(Xog_page hpg, Xodump_stats_itm hzip, int wtxt_len, int row_orig_len, int row_zip_len) {
|
||||
public void Insert(Xoh_page hpg, Hzip_stat_itm hzip, int wtxt_len, int row_orig_len, int row_zip_len) {
|
||||
Xopg_module_mgr js_mgr = hpg.Head_mgr();
|
||||
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
stmt_insert.Clear()
|
||||
@@ -48,7 +48,7 @@ public class Xodump_stats_tbl implements RlsAble {
|
||||
.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.Page_body()))
|
||||
.Val_int(fld_body_len , Len_or_0(hpg.Body()))
|
||||
.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()))
|
||||
@@ -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.hzips.tests; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.htmls.core.hzips.stats.*;
|
||||
public class Xoh_hzip_fxt {
|
||||
private final Bry_bfr bfr = Bry_bfr.new_();
|
||||
private final Xoh_hzip_mgr hzip_mgr;
|
||||
private final Hzip_stat_itm stat_itm = new Hzip_stat_itm();
|
||||
public Xoh_hzip_fxt() {
|
||||
parser_fxt.Wiki().Html__hdump_mgr().Init_by_db(parser_fxt.Wiki());
|
||||
this.hzip_mgr = parser_fxt.Wiki().Html__hdump_mgr().Hzip_mgr().Hzip_mgr();
|
||||
}
|
||||
public Xop_fxt Parser_fxt() {return parser_fxt;} private final Xop_fxt parser_fxt = new Xop_fxt();
|
||||
public void Test__encode(String hzip, String html) {
|
||||
Gfo_usr_dlg_.Instance = Gfo_usr_dlg_.Test_console();
|
||||
hzip_mgr.Encode(bfr, parser_fxt.Wiki(), Bry_.Empty, Bry_.new_u8(html), stat_itm);
|
||||
Gfo_usr_dlg_.Instance = Gfo_usr_dlg_.Noop;
|
||||
Tfds.Eq_str_lines(hzip, bfr.To_str_and_clear());
|
||||
}
|
||||
public void Test__decode(String hzip, String html) {
|
||||
Gfo_usr_dlg_.Instance = Gfo_usr_dlg_.Test_console();
|
||||
byte[] actl = hzip_mgr.Decode(bfr, parser_fxt.Wiki(), Bry_.Empty, Bry_.new_u8(hzip));
|
||||
Gfo_usr_dlg_.Instance = Gfo_usr_dlg_.Noop;
|
||||
Tfds.Eq_str_lines(html, String_.new_u8(actl));
|
||||
}
|
||||
public void Test__bicode(String hzip, String html) {
|
||||
hzip = Xoh_hzip_fxt.Escape(hzip);
|
||||
Test__encode(hzip, html);
|
||||
Test__decode(hzip, html);
|
||||
}
|
||||
public static String Escape(String v) {return String_.Replace(v, "~", "");}
|
||||
}
|
||||
136
400_xowa/src/gplx/xowa/htmls/core/makes/Xoh_make_mgr.java
Normal file
136
400_xowa/src/gplx/xowa/htmls/core/makes/Xoh_make_mgr.java
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
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.core.brys.*; 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.apps.fsys.*;
|
||||
import gplx.xowa.htmls.core.wkrs.hdrs.*;
|
||||
public class Xoh_make_mgr {
|
||||
private final Bry_bfr bfr = Bry_bfr.reset_(255), tmp_bfr = Bry_bfr.reset_(255); private final Bry_rdr bry_rdr = new Bry_rdr(); 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 Xoh_hdr_make wkr__hdr = new Xoh_hdr_make();
|
||||
private final Bry_parser parser = new Bry_parser();
|
||||
public Xoh_make_mgr(Gfo_usr_dlg usr_dlg, Xoa_fsys_mgr fsys_mgr, 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(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_src(hpg.Url_bry_safe(), src, src_len, 0);
|
||||
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;
|
||||
case Xoh_make_trie_.Tid__hdr: return wkr__hdr.Make(bfr, hpg, parser, src, hook_bgn);
|
||||
}
|
||||
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, 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, 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_base.box_style_max_width_fmtr.Bld_bry_many(tmp_bfr, gly.Box_max());
|
||||
Html_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Html_atr_.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_base.hdump_box_w_fmtr.Bld_bry_many(tmp_bfr, gly.Box_w());
|
||||
Html_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Html_atr_.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_base.hdump_box_w_fmtr.Bld_bry_many(tmp_bfr, gly.Img_w());
|
||||
Html_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Html_atr_.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_base.hdump_img_pad_fmtr.Bld_bry_many(tmp_bfr, gly.Img_pad());
|
||||
Html_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Html_atr_.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();
|
||||
}
|
||||
@@ -15,14 +15,14 @@ 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.hdumps.abrvs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hdumps.*;
|
||||
import org.junit.*; import gplx.core.primitives.*; import gplx.xowa.htmls.hdumps.core.*; import gplx.xowa.htmls.hdumps.data.*; import gplx.xowa.files.*; import gplx.xowa.parsers.lnkis.*;
|
||||
import gplx.xowa.guis.*;
|
||||
public class Xohd_abrv_mgr_tst {
|
||||
package gplx.xowa.htmls.core.makes; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import org.junit.*;
|
||||
public class Xoh_make_mgr__file__tst {
|
||||
private final Xoh_make_mgr_fxt fxt = new Xoh_make_mgr_fxt();
|
||||
@Before public void init() {
|
||||
fxt.Clear();
|
||||
fxt.Init_data_img_basic("A.png", 0, 220, 110);
|
||||
} private final Xohd_abrv_mgr_fxt fxt = new Xohd_abrv_mgr_fxt();
|
||||
}
|
||||
@Test public void Img() {
|
||||
fxt .Init_body("<img xowa_img='0' />")
|
||||
.Test_html("<img src='file:///mem/xowa/file/commons.wikimedia.org/thumb/7/0/A.png/220px.png' width='220' height='110' />");
|
||||
@@ -87,67 +87,4 @@ public class Xohd_abrv_mgr_tst {
|
||||
, " <div style=\"margin:15px auto;\">"
|
||||
));
|
||||
}
|
||||
@Test public void Redlink() {
|
||||
fxt .Init_data_redlink(1, 2);
|
||||
fxt .Init_body(String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"/wiki/A\" xowa_redlink='1'>A</a>"
|
||||
, "<a href=\"/wiki/B\" xowa_redlink='2'>B</a>"
|
||||
, "<a href=\"/wiki/C\" xowa_redlink='3'>C</a>"
|
||||
))
|
||||
.Test_html(String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"/wiki/A\" class='new'>A</a>"
|
||||
, "<a href=\"/wiki/B\" class='new'>B</a>"
|
||||
, "<a href=\"/wiki/C\">C</a>"
|
||||
));
|
||||
}
|
||||
}
|
||||
class Xohd_abrv_mgr_fxt {
|
||||
private Xohd_abrv_mgr abrv_mgr;
|
||||
private Bry_bfr bfr = Bry_bfr.reset_(255);
|
||||
private List_adp img_list = List_adp_.new_();
|
||||
private Xowe_wiki wiki;
|
||||
public Xog_page Hpg() {return hpg;} private Xog_page hpg = new Xog_page();
|
||||
public void Clear() {
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
wiki = Xoa_app_fxt.wiki_tst_(app);
|
||||
abrv_mgr = new Xohd_abrv_mgr(Gfo_usr_dlg_.Instance, app.Fsys_mgr(), app.Utl__encoder_mgr().Fsys(), wiki.Domain_bry());
|
||||
}
|
||||
public void Clear_imgs() {img_list.Clear();}
|
||||
public Xohd_abrv_mgr_fxt Init_body(String body) {hpg.Page_body_(Bry_.new_u8(body)); return this;}
|
||||
public Xohd_abrv_mgr_fxt Init_data_gly(int uid, int box_max) {hpg.Gallery_itms().Add(uid, new Xohd_data_itm__gallery_mgr(uid, box_max)); return this;}
|
||||
public Xohd_abrv_mgr_fxt Init_data_img_basic(String ttl, int html_uid, int html_w, int html_h) {
|
||||
Xohd_data_itm__img img = new Xohd_data_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_data_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 Xohd_abrv_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_data_itm__gallery_itm img = new Xohd_data_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_data_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 Xohd_abrv_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 Xohd_abrv_mgr_fxt Test_html(String expd) {
|
||||
if (img_list.Count() > 0) hpg.Img_itms_((Xohd_data_itm__base[])img_list.To_ary_and_clear(Xohd_data_itm__base.class));
|
||||
byte[] actl = abrv_mgr.Parse(bfr, hpg);
|
||||
Tfds.Eq_str_lines(expd, String_.new_u8(actl));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
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.app_();
|
||||
this.wiki = Xoa_app_fxt.wiki_tst_(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, hpg.Body());
|
||||
Tfds.Eq_str_lines(expd, String_.new_u8(actl));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
67
400_xowa/src/gplx/xowa/htmls/core/makes/Xoh_make_trie_.java
Normal file
67
400_xowa/src/gplx/xowa/htmls/core/makes/Xoh_make_trie_.java
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
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__hdr , Byte_ascii.Escape , Xoh_html_dict_.Type__hdr);
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.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;
|
||||
}
|
||||
@@ -15,8 +15,8 @@ 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.hdumps.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hdumps.*;
|
||||
public interface Xohd_data_itm {
|
||||
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();
|
||||
@@ -15,11 +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.hdumps.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hdumps.*;
|
||||
import gplx.core.brys.*; import gplx.xowa.htmls.hdumps.data.*; import gplx.xowa.files.repos.*;
|
||||
public abstract class Xohd_data_itm__base implements Xohd_data_itm {
|
||||
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_data_tid.Tid_img;}
|
||||
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;
|
||||
@@ -36,7 +36,7 @@ public abstract class Xohd_data_itm__base implements Xohd_data_itm {
|
||||
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_data_itm__base Data_init_base
|
||||
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
|
||||
@@ -48,7 +48,7 @@ public abstract class Xohd_data_itm__base implements Xohd_data_itm {
|
||||
return this;
|
||||
}
|
||||
public void Data_write(Bry_bfr bfr) {
|
||||
bfr .Add_int_variable(Xohd_data_tid.Tid_img).Add_byte_pipe()
|
||||
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()
|
||||
@@ -97,5 +97,5 @@ public abstract class Xohd_data_itm__base implements Xohd_data_itm {
|
||||
, File_repo_id_local = Xof_repo_itm_.Repo_local
|
||||
, File_repo_id_null = Xof_repo_itm_.Repo_null
|
||||
;
|
||||
public static final Xohd_data_itm__base[] Ary_empty = new Xohd_data_itm__base[0];
|
||||
public static final Xohd_img_itm__base[] Ary_empty = new Xohd_img_itm__base[0];
|
||||
}
|
||||
@@ -15,15 +15,15 @@ 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.hdumps.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hdumps.*;
|
||||
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_data_itm__gallery_itm extends Xohd_data_itm__base {
|
||||
@Override public int Img_tid() {return Xohd_data_itm__base.Tid_gallery;}
|
||||
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_data_itm__gallery_itm Data_init_gallery(int box_w, int img_w, 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;
|
||||
@@ -15,15 +15,15 @@ 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.hdumps.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hdumps.*;
|
||||
public class Xohd_data_itm__gallery_mgr implements Xohd_data_itm {
|
||||
public Xohd_data_itm__gallery_mgr(int uid, int box_max) {
|
||||
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_data_tid.Tid_gallery;}
|
||||
public int Data_tid() {return Xohd_img_tid.Tid_gallery;}
|
||||
public void Data_write(Bry_bfr bfr) {
|
||||
bfr .Add_int_variable(Xohd_data_tid.Tid_gallery).Add_byte_pipe()
|
||||
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()
|
||||
;
|
||||
@@ -15,9 +15,9 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.hdumps.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hdumps.*;
|
||||
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_data_itm__img extends Xohd_data_itm__base {
|
||||
@Override public int Img_tid() {return Xohd_data_itm__base.Tid_basic;}
|
||||
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;}
|
||||
}
|
||||
@@ -15,8 +15,8 @@ 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.hdumps.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hdumps.*;
|
||||
public class Xohd_data_tid { // SERIALIZED
|
||||
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
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.makes.tests; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.makes.*;
|
||||
import gplx.xowa.htmls.sections.*;
|
||||
public class Xoh_make_fxt {
|
||||
public Xoh_make_fxt() {
|
||||
parser_fxt.Wiki().Html__hdump_mgr().Init_by_db(parser_fxt.Wiki());
|
||||
parser_fxt.Wiki().Html_mgr().Html_wtr().Cfg().Lnki__id_(Bool_.Y).Lnki__title_(Bool_.Y);
|
||||
}
|
||||
public void Clear() {parser_fxt.Reset();}
|
||||
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 Test__html(String wtxt, String expd) {
|
||||
Tfds.Eq_str_lines(expd, parser_fxt.Exec__parse_to_hdump(wtxt));
|
||||
}
|
||||
public void Test__make(String html, Xoh_page_chkr chkr) {
|
||||
Xoh_page actl = new Xoh_page();
|
||||
Gfo_usr_dlg_.Instance = Gfo_usr_dlg_.Test_console();
|
||||
byte[] actl_body = parser_fxt.Wiki().Html__hdump_mgr().Load_mgr().Make_mgr().Parse(actl, Bry_.new_u8(html));
|
||||
actl.Body_(actl_body);
|
||||
Gfo_usr_dlg_.Instance = Gfo_usr_dlg_.Noop;
|
||||
chkr.Check(actl);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
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.tests; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.makes.*;
|
||||
import gplx.xowa.htmls.sections.*;
|
||||
public class Xoh_page_chkr {
|
||||
private final Xoh_section_mgr expd_section_mgr = new Xoh_section_mgr();
|
||||
private final Bry_bfr bfr = Bry_bfr.new_();
|
||||
public Xoh_page_chkr Body_(String v) {this.expd_body = v; return this;} private String expd_body;
|
||||
public Xoh_page_chkr Sections__add(int uid, int level, String anchor, String display, String content) {
|
||||
expd_section_mgr.Add(uid, level, Bry_.new_u8(anchor), Bry_.new_u8(display)).Content_(Bry_.new_u8(content));
|
||||
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_section_mgr.Len() > 0)
|
||||
Tfds.Eq_str_lines(To_str__section_mgr(expd_section_mgr), To_str__section_mgr(actl.Section_mgr()));
|
||||
}
|
||||
private String To_str__section_mgr(Xoh_section_mgr expd_section_mgr) {
|
||||
expd_section_mgr.To_bfr(bfr);
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
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.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.core.btries.*; import gplx.core.primitives.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.parsers.*;
|
||||
import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.core.wkrs.lnkes.*; import gplx.xowa.htmls.core.wkrs.lnkis.*; import gplx.xowa.htmls.core.wkrs.hdrs.*;
|
||||
import gplx.xowa.wikis.ttls.*;
|
||||
class Xoh_doc_wkr__tag implements Html_doc_wkr {
|
||||
private final Html_tag_rdr rdr = new Html_tag_rdr();
|
||||
private byte[] src; private Xoh_wkr wkr;
|
||||
private final Xoh_lnki_parse wkr__lnki = new Xoh_lnki_parse();
|
||||
private final Xoh_lnke_parse wkr__lnke = new Xoh_lnke_parse();
|
||||
private final Xoh_hdr_parse wkr__hdr = new Xoh_hdr_parse();
|
||||
private Xow_ttl_parser ttl_parser;
|
||||
public byte[] Hook() {return Byte_ascii.Angle_bgn_bry;}
|
||||
public Xoh_doc_wkr__tag(Xoh_wkr wkr, Xow_ttl_parser ttl_parser) {
|
||||
this.wkr = wkr; this.ttl_parser = ttl_parser;
|
||||
}
|
||||
public void Init(byte[] src, int src_bgn, int src_end) {
|
||||
this.src = src;
|
||||
rdr.Init(src, src_bgn, src_end);
|
||||
}
|
||||
public int Parse(int pos) {
|
||||
rdr.Pos_(pos);
|
||||
Html_tag cur = rdr.Tag__move_fwd_head();
|
||||
int cur_name_id = cur.Name_id();
|
||||
switch (cur_name_id) {
|
||||
case Html_tag_.Id__h2:
|
||||
case Html_tag_.Id__h3:
|
||||
case Html_tag_.Id__h4:
|
||||
case Html_tag_.Id__h5:
|
||||
case Html_tag_.Id__h6:
|
||||
int hdr_tag_bgn = cur.Src_bgn();
|
||||
Html_tag nxt = rdr.Tag__peek_fwd_head();
|
||||
if ( nxt.Name_id() == Html_tag_.Id__span
|
||||
&& nxt.Atrs__match_pair(Html_atr_.Bry__class , Atr__class__mw_headline)) {
|
||||
return wkr__hdr.Parse(wkr, rdr, src, cur_name_id, hdr_tag_bgn, nxt);
|
||||
}
|
||||
break;
|
||||
case Html_tag_.Id__a:
|
||||
if (cur.Atrs__match_pair(Html_atr_.Bry__rel , Atr__rel__nofollow))
|
||||
return wkr__lnke.Parse(wkr, rdr, src, cur);
|
||||
else if (cur.Atrs__match_pair(Html_atr_.Bry__class , Atr__class__image)) {
|
||||
// <a href="/wiki/File:A.png" class="image"><img alt="A" src="//upload.wikimedia.org/wikipedia/commons/thumb/7/70/A.png/220px-A.svg.png" width="220" height="149" /></a>
|
||||
}
|
||||
else
|
||||
return wkr__lnki.Parse(wkr, rdr, src, cur, ttl_parser);
|
||||
break;
|
||||
}
|
||||
return cur.Src_end();
|
||||
}
|
||||
private static final byte[]
|
||||
Atr__class__mw_headline = Bry_.new_a7("mw-headline")
|
||||
, Atr__class__image = Bry_.new_a7("image")
|
||||
, Atr__rel__nofollow = Bry_.new_a7("nofollow")
|
||||
;
|
||||
}
|
||||
30
400_xowa/src/gplx/xowa/htmls/core/parsers/Xoh_parser_.java
Normal file
30
400_xowa/src/gplx/xowa/htmls/core/parsers/Xoh_parser_.java
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.langs.htmls.parsers.*; import gplx.xowa.htmls.core.wkrs.txts.*; import gplx.xowa.htmls.core.wkrs.escapes.*; import gplx.xowa.htmls.core.wkrs.spaces.*;
|
||||
public class Xoh_parser_ {
|
||||
public static Html_doc_parser new_(Xoh_wkr wkr, Xow_wiki wiki) {
|
||||
Html_doc_parser rv = new Html_doc_parser();
|
||||
rv.Reg_txt(new Xoh_txt_parse(wkr)).Reg
|
||||
( new Xoh_doc_wkr__tag(wkr, wiki)
|
||||
, new Xoh_escape_parse(wkr)
|
||||
, new Xoh_space_parse(wkr)
|
||||
);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
100
400_xowa/src/gplx/xowa/htmls/core/parsers/Xoh_parser_fxt.java
Normal file
100
400_xowa/src/gplx/xowa/htmls/core/parsers/Xoh_parser_fxt.java
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
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.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.langs.htmls.parsers.*;
|
||||
public class Xoh_parser_fxt {
|
||||
private final Html_doc_parser parser;
|
||||
private final Xoh_wkr__test actl_wkr = new Xoh_wkr__test(), expd_wkr = new Xoh_wkr__test();
|
||||
public Xoh_parser_fxt() {
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
this.wiki = Xoa_app_fxt.wiki_tst_(app);
|
||||
parser = Xoh_parser_.new_(actl_wkr, wiki);
|
||||
}
|
||||
public Xow_wiki Wiki() {return wiki;} private Xow_wiki wiki;
|
||||
public void Test__parse(String src_str) {
|
||||
byte[] src_bry = Bry_.new_u8(src_str);
|
||||
parser.Parse(src_bry, 0, src_bry.length);
|
||||
Tfds.Eq_ary_str(expd_wkr.To_ary(), actl_wkr.To_ary());
|
||||
}
|
||||
public void Init__hdr(int rng_bgn, int rng_end, int level, String id, String caption, boolean id_caption_related) {
|
||||
expd_wkr.On_hdr(rng_bgn, rng_end, level, Bry_.new_u8(id), Bry_.new_u8(caption), id_caption_related);
|
||||
}
|
||||
public void Init__lnke(int rng_bgn, int rng_end, byte lnke_type, int autonumber_id, String href) {
|
||||
expd_wkr.On_lnke(rng_bgn, rng_end, lnke_type, autonumber_id, Bry_.new_u8(href));
|
||||
}
|
||||
public void Init__lnki(int rng_bgn, int rng_end, byte lnki_type, int site_bgn, int site_end, String page_str, String capt_str, String trail_str) {
|
||||
expd_wkr.On_lnki(rng_bgn, rng_end, lnki_type, site_bgn, site_end, Bry_.new_u8(page_str), Bry_.new_u8(capt_str), Bry_.new_u8(trail_str));
|
||||
}
|
||||
public void Init__escape(int rng_bgn, int rng_end) {
|
||||
expd_wkr.On_escape(rng_bgn, rng_end);
|
||||
}
|
||||
public void Init__space(int rng_bgn, int rng_end) {
|
||||
expd_wkr.On_space(rng_bgn, rng_end);
|
||||
}
|
||||
public void Init__txt(int rng_bgn, int rng_end) {
|
||||
expd_wkr.On_txt(rng_bgn, rng_end);
|
||||
}
|
||||
}
|
||||
class Xoh_wkr__test implements Xoh_wkr {
|
||||
private final List_adp list = List_adp_.new_();
|
||||
private final Bry_bfr bfr = Bry_bfr.new_();
|
||||
public void On_hdr(int rng_bgn, int rng_end, int level, byte[] id, byte[] caption, boolean id_caption_related) {
|
||||
bfr.Add_int_variable(rng_bgn).Add_byte_pipe();
|
||||
bfr.Add_int_variable(rng_end).Add_byte_pipe();
|
||||
bfr.Add_int_variable(level).Add_byte_pipe();
|
||||
bfr.Add_safe(id).Add_byte_pipe();
|
||||
bfr.Add(caption).Add_byte_pipe();
|
||||
bfr.Add_bool(id_caption_related);
|
||||
list.Add(bfr.To_str_and_clear());
|
||||
}
|
||||
public void On_lnke(int rng_bgn, int rng_end, byte lnke_type, int autonumber_id, byte[] href) {
|
||||
bfr.Add_int_variable(rng_bgn).Add_byte_pipe();
|
||||
bfr.Add_int_variable(rng_end).Add_byte_pipe();
|
||||
bfr.Add_int_variable(lnke_type).Add_byte_pipe();
|
||||
bfr.Add_int_variable(autonumber_id).Add_byte_pipe();
|
||||
bfr.Add(href);
|
||||
list.Add(bfr.To_str_and_clear());
|
||||
}
|
||||
public void On_lnki(int rng_bgn, int rng_end, byte lnki_type, int site_bgn, int site_end, byte[] page_bry, byte[] capt_bry, byte[] trail_bry) {
|
||||
bfr.Add_int_variable(rng_bgn).Add_byte_pipe();
|
||||
bfr.Add_int_variable(rng_end).Add_byte_pipe();
|
||||
bfr.Add_byte(lnki_type).Add_byte_pipe();
|
||||
bfr.Add_int_variable(site_bgn).Add_byte_pipe();
|
||||
bfr.Add_int_variable(site_end).Add_byte_pipe();
|
||||
bfr.Add_safe(page_bry).Add_byte_pipe();
|
||||
bfr.Add_safe(capt_bry).Add_byte_pipe();
|
||||
bfr.Add_safe(trail_bry).Add_byte_pipe();
|
||||
list.Add(bfr.To_str_and_clear());
|
||||
}
|
||||
public void On_escape(int rng_bgn, int rng_end) {
|
||||
bfr.Add_int_variable(rng_bgn).Add_byte_pipe();
|
||||
bfr.Add_int_variable(rng_end).Add_byte_pipe();
|
||||
list.Add(bfr.To_str_and_clear());
|
||||
}
|
||||
public void On_space(int rng_bgn, int rng_end) {
|
||||
bfr.Add_int_variable(rng_bgn).Add_byte_pipe();
|
||||
bfr.Add_int_variable(rng_end).Add_byte_pipe();
|
||||
list.Add(bfr.To_str_and_clear());
|
||||
}
|
||||
public void On_txt(int rng_bgn, int rng_end) {
|
||||
bfr.Add_int_variable(rng_bgn).Add_byte_pipe();
|
||||
bfr.Add_int_variable(rng_end).Add_byte_pipe();
|
||||
list.Add(bfr.To_str_and_clear());
|
||||
}
|
||||
public String[] To_ary() {return list.To_str_ary_and_clear();}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
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.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.ttls.*;
|
||||
public class Xoh_ttl_matcher {
|
||||
public int Trail_bgn() {return trail_bgn;} private int trail_bgn;
|
||||
public byte Match(Xow_ttl_parser ttl_parser, byte[] page_bry, int page_bgn, int page_end, byte[] capt_bry, int capt_bgn, int capt_end) {
|
||||
trail_bgn = -1;
|
||||
int page_len = page_end - page_bgn;
|
||||
Xoa_ttl page = ttl_parser.Ttl_parse(page_bry, page_bgn, page_end); if (page == null) throw Err_.new_("", "invalid page", "page", page_bry);
|
||||
Xow_ns ns = page.Ns();
|
||||
if (ns.Id() != Xow_ns_.Id_main) {
|
||||
byte[] ns_name_txt = ns.Name_txt_w_colon(); // EX: 11="Template talk:"
|
||||
int ns_name_txt_len = ns_name_txt.length;
|
||||
int ns_name_txt_end = capt_bgn + ns_name_txt_len;
|
||||
if (Bry_.Match(capt_bry, capt_bgn, ns_name_txt_end, ns_name_txt, 0, ns_name_txt_len))
|
||||
capt_bgn = page_bgn = ns_name_txt_end;
|
||||
else
|
||||
return Tid__diff;
|
||||
}
|
||||
int capt_len = capt_end - capt_bgn;
|
||||
for (int i = 0; i < capt_len; ++i) {
|
||||
byte capt_byte = capt_bry[i + capt_bgn];
|
||||
if (i == page_len) {
|
||||
trail_bgn = i + capt_bgn;
|
||||
return Tid__trail;
|
||||
}
|
||||
byte page_byte = page_bry[i + page_bgn];
|
||||
if (page_byte == capt_byte) continue;
|
||||
if ( i == 0
|
||||
&& ns.Case_match() == Xow_ns_case_.Tid__1st
|
||||
&& capt_byte >= Byte_ascii.Ltr_a && capt_byte <= Byte_ascii.Ltr_z
|
||||
&& (capt_byte - page_byte) == 32
|
||||
)
|
||||
continue;
|
||||
if ( capt_byte == Byte_ascii.Space
|
||||
&& page_byte == Byte_ascii.Underline
|
||||
)
|
||||
continue;
|
||||
return Tid__diff;
|
||||
}
|
||||
return Tid__same;
|
||||
}
|
||||
public static final byte
|
||||
Tid__same = Byte_ascii.Num_1 // "A", "A"; "1|A"
|
||||
, Tid__diff = Byte_ascii.Num_2 // "A", "B"; "2|A|B"
|
||||
, Tid__trail = Byte_ascii.Num_3 // "A", "As"; "3|A|s"
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
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.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import org.junit.*;
|
||||
public class Xoh_ttl_matcher_tst {
|
||||
private final Xoh_ttl_matcher_fxt fxt = new Xoh_ttl_matcher_fxt();
|
||||
@Test public void Basic__same() {fxt.Test__match("Abc" , "Abc", Xoh_ttl_matcher.Tid__same);}
|
||||
@Test public void Basic__diff() {fxt.Test__match("Abc" , "ABC", Xoh_ttl_matcher.Tid__diff);}
|
||||
@Test public void Space__same() {fxt.Test__match("A_b" , "A b", Xoh_ttl_matcher.Tid__same);}
|
||||
@Test public void Case__same() {fxt.Test__match("Abc" , "abc", Xoh_ttl_matcher.Tid__same);}
|
||||
@Test public void Case__reverse() {fxt.Test__match("abc" , "Abc", Xoh_ttl_matcher.Tid__diff);}
|
||||
@Test public void Case__disabled() {
|
||||
fxt.Wiki().Ns_mgr().Ns_main().Case_match_(gplx.xowa.wikis.nss.Xow_ns_case_.Tid__all);
|
||||
fxt.Test__match("Abcde", "abcde", Xoh_ttl_matcher.Tid__diff);
|
||||
}
|
||||
@Test public void Ns__same() {fxt.Test__match("Help_talk:Ab" , "Help talk:Ab", Xoh_ttl_matcher.Tid__same);}
|
||||
@Test public void Ns__diff() {fxt.Test__match("Help_talk:Ab" , "Help_talk:Ab", Xoh_ttl_matcher.Tid__diff);}
|
||||
@Test public void Trail__same() {fxt.Test__match("A" , "Abc", Xoh_ttl_matcher.Tid__trail, 1);}
|
||||
}
|
||||
class Xoh_ttl_matcher_fxt {
|
||||
private final Xoh_ttl_matcher matcher = new Xoh_ttl_matcher();
|
||||
public Xoh_ttl_matcher_fxt() {
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
this.wiki = Xoa_app_fxt.wiki_tst_(app);
|
||||
}
|
||||
public Xow_wiki Wiki() {return wiki;} private Xow_wiki wiki;
|
||||
public void Test__match(String page_str, String capt_str, int expd_tid) {Test__match(page_str, capt_str, expd_tid, -1);}
|
||||
public void Test__match(String page_str, String capt_str, int expd_tid, int expd_trail_bgn) {
|
||||
byte[] page_bry = Bry_.new_u8(page_str);
|
||||
byte[] capt_bry = Bry_.new_u8(capt_str);
|
||||
Tfds.Eq_int(expd_tid , matcher.Match(wiki, page_bry, 0, page_bry.length, capt_bry, 0, capt_bry.length));
|
||||
Tfds.Eq_int(expd_trail_bgn , matcher.Trail_bgn());
|
||||
}
|
||||
}
|
||||
26
400_xowa/src/gplx/xowa/htmls/core/parsers/Xoh_wkr.java
Normal file
26
400_xowa/src/gplx/xowa/htmls/core/parsers/Xoh_wkr.java
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
public interface Xoh_wkr {
|
||||
void On_hdr (int tag_bgn, int tag_end, int level, byte[] id, byte[] caption, boolean id_caption_related);
|
||||
void On_lnke (int tag_bgn, int tag_end, byte lnke_type, int autonumber_id, byte[] href);
|
||||
void On_lnki (int tag_bgn, int tag_end, byte lnki_type, int site_bgn, int site_end, byte[] page_bry, byte[] capt_bry, byte[] trail_bry);
|
||||
void On_escape (int rng_bgn, int rng_end);
|
||||
void On_space (int rng_bgn, int rng_end);
|
||||
void On_txt (int rng_bgn, int rng_end);
|
||||
}
|
||||
32
400_xowa/src/gplx/xowa/htmls/core/parsers/Xoh_wkr__hzip.java
Normal file
32
400_xowa/src/gplx/xowa/htmls/core/parsers/Xoh_wkr__hzip.java
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
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.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.xowa.htmls.core.wkrs.lnkes.*;
|
||||
class Xoh_wkr__hzip implements Xoh_wkr {
|
||||
// private final Bry_bfr bfr = Bry_bfr.new_();
|
||||
// private final Xoh_lnke_hzip wkr__lnke = new Xoh_lnke_hzip();
|
||||
// private byte[] src = null;
|
||||
public void On_hdr (int tag_bgn, int tag_end, int level, byte[] id, byte[] caption, boolean id_caption_related) {}
|
||||
public void On_lnke (int tag_bgn, int tag_end, byte lnke_type, int autonumber_id, byte[] href) {
|
||||
// wkr__lnke.Encode_exec(bfr, src, tag_bgn, tag_end, lnke_type, href, autonumber_id);
|
||||
}
|
||||
public void On_lnki (int tag_bgn, int tag_end, byte lnki_type, int site_bgn, int site_end, byte[] page_bry, byte[] capt_bry, byte[] trail_bry) {}
|
||||
public void On_escape (int rng_bgn, int rng_end) {}
|
||||
public void On_space (int rng_bgn, int rng_end) {}
|
||||
public void On_txt (int rng_bgn, int rng_end) {}
|
||||
}
|
||||
111
400_xowa/src/gplx/xowa/htmls/core/to_delete/Xoh_hzip_href.java
Normal file
111
400_xowa/src/gplx/xowa/htmls/core/to_delete/Xoh_hzip_href.java
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
//namespace gplx.xowa.htmls.core.hzips.wkrs {
|
||||
// using gplx.core.btries;
|
||||
// using gplx.xowa.htmls.core.hzips.stats;
|
||||
// public class Xoh_hzip_href {
|
||||
// public void Save(Bry_bfr bfr, Hzip_stat_itm stats, byte[] src, int src_len, int bgn, int pos, byte bgn_quote) {
|
||||
//// // ignore anchors; EX: "#a"
|
||||
//// int proto_bgn = pos;
|
||||
//// int proto_end = Bry_find_.Find_fwd(src, Byte_ascii.Colon, proto_bgn, src_len);
|
||||
//// byte proto_tid = Tid_proto_other;
|
||||
//// if (proto_end != Bry_find_.Not_found) {
|
||||
//// Object proto_obj = proto_trie.Match_exact(src, pos, proto_bgn);
|
||||
//// if (proto_obj != null)
|
||||
//// proto_tid = ((Byte_obj_val)proto_obj).Val();
|
||||
//// pos = Bry_find_.Find_fwd_while(src, proto_bgn + 1, src_len, Byte_ascii.Slash); // eat /; EX: http:// should position after /
|
||||
//// }
|
||||
//// // stats.Lnke_proto_reg(proto_tid, src, proto_bgn, proto_end);
|
||||
////
|
||||
//// int domain_bgn = pos;
|
||||
//// int domain_end = Bry_find_.Find_fwd(src, Byte_ascii.Slash, domain_bgn, src_len);
|
||||
//// if (domain_end == Bry_find_.Not_found) // href has no slash; assume entire String is domain EX: "www.a.org"
|
||||
//// domain_end = Bry_find_.Find_fwd(src, bgn_quote, pos, src_len);
|
||||
////
|
||||
//// int tld_pos = Bry_find_.Find_bwd(src, Byte_ascii.Dot, domain_bgn, src_len);
|
||||
//// byte tld_tid = Tid_tld_other;
|
||||
//// if (tld_pos != Bry_find_.Not_found) {
|
||||
//// Object tld_obj = tld_trie.Match_exact(src, domain_bgn, domain_end);
|
||||
//// if (tld_obj != null)
|
||||
//// tld_tid = ((Byte_obj_val)tld_obj).Val();
|
||||
//// pos = Bry_find_.Find_fwd_while(src, domain_bgn + 1, src_len, Byte_ascii.Slash); // eat /; EX: http:// should position after /
|
||||
//// }
|
||||
//// // stats.Lnke_tld_reg(tld_tid, src, domain_bgn, domain_end);
|
||||
// }
|
||||
// public static final byte // 2
|
||||
// Tid_proto_other = 0
|
||||
// , Tid_proto_http = 1
|
||||
// , Tid_proto_https = 2
|
||||
// ;
|
||||
// public static final byte // 3
|
||||
// Tid_tld_other = 0
|
||||
// , Tid_tld_com = 1
|
||||
// , Tid_tld_org = 2
|
||||
// , Tid_tld_net = 3
|
||||
// , Tid_tld_gov = 4
|
||||
// ;
|
||||
// public static final byte // 3
|
||||
// Tid_ext_other = 0
|
||||
// , Tid_ext_none = 1
|
||||
// , Tid_ext_htm = 2
|
||||
// , Tid_ext_html = 3
|
||||
// , Tid_ext_php = 4
|
||||
// , Tid_ext_jsp = 5
|
||||
// , Tid_ext_asp = 6
|
||||
// , Tid_ext_aspx = 7
|
||||
// ;
|
||||
//// private static final Btrie_slim_mgr proto_trie = Btrie_slim_mgr.ci_a7()
|
||||
//// .Add_str_byte("http", Tid_proto_http)
|
||||
//// .Add_str_byte("https", Tid_proto_http)
|
||||
//// ;
|
||||
//// private static final Btrie_slim_mgr tld_trie = Btrie_slim_mgr.ci_a7()
|
||||
//// .Add_str_byte("com", Tid_tld_com)
|
||||
//// .Add_str_byte("org", Tid_tld_org)
|
||||
//// .Add_str_byte("net", Tid_tld_net)
|
||||
//// .Add_str_byte("gov", Tid_tld_gov)
|
||||
//// ;
|
||||
//// private static final Btrie_slim_mgr ext_trie = Btrie_slim_mgr.ci_a7()
|
||||
//// .Add_str_byte("htm", Tid_ext_htm)
|
||||
//// .Add_str_byte("html", Tid_ext_html)
|
||||
//// .Add_str_byte("php", Tid_ext_php)
|
||||
//// .Add_str_byte("jsp", Tid_ext_jsp)
|
||||
//// .Add_str_byte("asp", Tid_ext_asp)
|
||||
//// .Add_str_byte("aspx", Tid_ext_aspx)
|
||||
//// ;
|
||||
// // <a href="/site/simple.wikipedia.org/wiki/Template:Solar_System?action=edit"><span title="Edit this template" style="">e</span></a> // xwiki [[simple:xx
|
||||
// // <a href="http://planetarynames.wr.usgs.gov/jsp/append5.jsp" class="external text" rel="nofollow">"Descriptor Terms (Feature Types)"</a>
|
||||
// /*
|
||||
// 0: proto,tld,ext
|
||||
// 1-n: domain
|
||||
// n: 0: domain_end
|
||||
// n: url remainder
|
||||
// n: 0: url_end
|
||||
// */
|
||||
// }
|
||||
//}
|
||||
//namespace gplx.xowa.htmls.core.hzips.wkrs {
|
||||
// import org.junit.*; using gplx.xowa.htmls;
|
||||
// public class Xoh_hzip_href_tst {
|
||||
// @Before public void init() {fxt.Clear();} private Xoh_hzip_mgr_fxt fxt = new Xoh_hzip_mgr_fxt();
|
||||
// @Test public void Srl_lnki_img_full() {
|
||||
// byte[][] brys = Bry_.Ary(Xoh_hzip_dict_.Bry__img_full, Bry_.new_ints(7), fxt.Make_int(12), Bry_.new_a7("cls_other"), Bry_.new_a7("|caption_other"), Xoh_hzip_dict_.Escape_bry);
|
||||
// fxt.Test_save(brys, "<a xtid='a_img_full' xatrs='1|1|1|12|cls_other|caption_other'/>");
|
||||
//// fxt.Test_load(brys, "a_1<a href='/wiki/A' title='A'>A</a>a_2");
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
//namespace gplx.xowa.htmls.core.to_delete {
|
||||
// using gplx.core.primitives; using gplx.core.brys; using gplx.core.btries; using gplx.dbs; using gplx.core.ios;
|
||||
// using gplx.xowa.wikis.dbs; using gplx.xowa.wikis.pages; using gplx.xowa.htmls.core.makes.imgs; using gplx.xowa.wikis.pages.skins;
|
||||
// using gplx.xowa.wikis.data; using gplx.xowa.wikis.data.tbls; using gplx.xowa.guis;
|
||||
// public class Xohd_page_html_mgr__load {
|
||||
// private final Bry_rdr rdr = new Bry_rdr(); private final List_adp rows = List_adp_.new_(), imgs = List_adp_.new_();
|
||||
// public void Load_page(Xow_wiki wiki, Xoh_page hpg, Xowd_html_tbl tbl, int page_id, Xoa_ttl page_ttl) {
|
||||
// Xoa_app_.Usr_dlg().Plog_many("", "", "hdump.load.text: ttl=~{0}", page_ttl.Full_db_as_str());
|
||||
// tbl.Select_by_page(rows, page_id);
|
||||
// Parse_rows(wiki, hpg, page_id, Xoa_url.blank(), page_ttl, rows);
|
||||
// }
|
||||
// public void Parse_rows(Xow_wiki wiki, Xoh_page hpg, int page_id, Xoa_url page_url, Xoa_ttl page_ttl, List_adp rows) { // TEST:
|
||||
// hpg.Init(wiki, page_id, page_url, page_ttl);
|
||||
// imgs.Clear();
|
||||
// int len = rows.Count();
|
||||
// for (int i = 0; i < len; ++i) {
|
||||
// Xowd_html_row row = (Xowd_html_row)rows.Get_at(i);
|
||||
// switch (row.Tid()) {
|
||||
// case Xowd_html_row.Tid__img:
|
||||
// case Xowd_html_row.Tid__redlink:
|
||||
// Parse_data(hpg, row); break;
|
||||
// }
|
||||
// }
|
||||
// rows.Clear();
|
||||
// }
|
||||
// private void Parse_data(Xoh_page hpg, Xowd_html_row row) {
|
||||
// rdr.Init(row.Data());
|
||||
// while (!rdr.Pos_is_eos()) {
|
||||
// int tid = rdr.Read_int_to_pipe();
|
||||
// switch (tid) {
|
||||
// case Xohd_img_tid.Tid_img : Load_data_img(); break; // 1|0|A.png|0|220|110|...
|
||||
// case Xohd_img_tid.Tid_gallery : Load_data_gallery(hpg); break; // 3|0|800
|
||||
// case Xohd_img_tid.Tid_redlink : Load_data_redlink(hpg); break; // 2|2|0|1
|
||||
// }
|
||||
// }
|
||||
// if (imgs.Count() > 0) hpg.Img_itms_((Xohd_img_itm__base[])imgs.To_ary_and_clear(typeof(Xohd_img_itm__base)));
|
||||
// }
|
||||
// public static Xohd_img_itm__base Load_img(Bry_rdr rdr) {
|
||||
// int tid = rdr.Read_int_to_pipe();
|
||||
// Xohd_img_itm__base img_itm = null;
|
||||
// switch (tid) {
|
||||
// case Xohd_img_itm__base.Tid_basic : img_itm = new Xohd_img_itm__img(); break;
|
||||
// case Xohd_img_itm__base.Tid_gallery : img_itm = new Xohd_img_itm__gallery_itm(); break;
|
||||
// default : throw Err_.new_unhandled(tid);
|
||||
// }
|
||||
// img_itm.Data_parse(rdr);
|
||||
// // Xoa_app_.Usr_dlg().Log_many("", "", "itm: ~{0}", img_itm.Data_print());
|
||||
// rdr.Pos_add_one();
|
||||
// return img_itm;
|
||||
// }
|
||||
// private void Load_data_img() {
|
||||
// Xohd_img_itm__base img = Load_img(rdr);
|
||||
// if (img == null) return;
|
||||
// imgs.Add(img);
|
||||
// }
|
||||
// private void Load_data_redlink(Xoh_page hpg) {
|
||||
// Ordered_hash redlink_hash = hpg.Redlink_uids();
|
||||
// while (!rdr.Pos_is_eos()) {
|
||||
// Int_obj_ref redlink_uid = Int_obj_ref.new_(rdr.Read_int_to_pipe());
|
||||
// redlink_hash.Add(redlink_uid, redlink_uid);
|
||||
// }
|
||||
// }
|
||||
// private void Load_data_gallery(Xoh_page hpg) {
|
||||
// int uid = rdr.Read_int_to_pipe();
|
||||
// int box_max = rdr.Read_int_to_pipe();
|
||||
// hpg.Gallery_itms().Add_if_dupe_use_nth(uid, new Xohd_img_itm__gallery_mgr(uid, box_max)); // TODO: temporarily added b/c last build did not add gallery uid correctly
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -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/>.
|
||||
*/
|
||||
//namespace gplx.xowa.htmls.core.to_delete {
|
||||
// using gplx.xowa.wikis.data; using gplx.xowa.wikis.data.tbls; using gplx.xowa.htmls.core.makes.imgs;
|
||||
// using gplx.xowa.guis; using gplx.xowa.wikis.pages; using gplx.xowa.parsers.lnkis.redlinks;
|
||||
// public class Xohd_page_html_mgr__save {
|
||||
// public void Update(Bry_bfr tmp_bfr, Xowd_html_tbl tbl, Xoae_page page) {
|
||||
// Xoh_page hpg = new Xoh_page().Ctor_by_page(tmp_bfr, page);
|
||||
// tbl.Delete(page.Revision_data().Id());
|
||||
// this.Insert(tmp_bfr, tbl, hpg, page.Hdump_data());
|
||||
// }
|
||||
// public int Insert(Bry_bfr tmp_bfr, Xowd_html_tbl tbl, Xoh_page hpg, Xopg_hdump_data hdump_data) {
|
||||
// int rv = 0;
|
||||
// int page_id = hpg.Page_id();
|
||||
// rv += Insert_row(tbl, page_id, Xowd_html_row.Tid__img , Write_imgs(tmp_bfr, hdump_data.Imgs()));
|
||||
// rv += Insert_row(tbl, page_id, Xowd_html_row.Tid__redlink , Write_redlinks(tmp_bfr, hdump_data.Redlink_mgr()));
|
||||
// return rv;
|
||||
// }
|
||||
// private int Insert_row(Xowd_html_tbl tbl, int page_id, int row_tid, byte[] bry) {return bry == null ? 0 : tbl.Insert(page_id, row_tid, bry);}
|
||||
// public static byte[] Write_redlinks(Bry_bfr bfr, Xopg_redlink_idx_list redlink_mgr) {
|
||||
// int len = redlink_mgr.Len(); if (len == 0) return null;
|
||||
// for (int i = 0; i < len; ++i)
|
||||
// bfr.Add_int_variable(redlink_mgr.Get_at(i)).Add_byte_pipe();
|
||||
// return bfr.To_bry_and_clear();
|
||||
// }
|
||||
// public static byte[] Write_imgs(Bry_bfr bfr, List_adp imgs) {
|
||||
// int len = imgs.Count(); if (len == 0) return null; // no images; exit early, else will write blank String
|
||||
// for (int i = 0; i < len; ++i) {
|
||||
// Xohd_img_itm itm = (Xohd_img_itm)imgs.Get_at(i);
|
||||
// itm.Data_write(bfr);
|
||||
// }
|
||||
// return bfr.To_bry_and_clear();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.escapes; 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.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.hzips.stats.*;
|
||||
public class Xoh_escape_hzip implements Xoh_hzip_wkr {
|
||||
public String Key() {return Xoh_hzip_dict_.Key__escape;}
|
||||
public void Encode(Bry_bfr bfr, Hzip_stat_itm stat_itm, Bry_parser parser, byte[] src, int hook_bgn) {// " " -> 27,9,4
|
||||
stat_itm.Escape_add_one();
|
||||
bfr.Add(Xoh_hzip_dict_.Bry__escape);
|
||||
}
|
||||
public int Decode(Bry_bfr bfr, Bry_parser parser, byte[] src, int hook_bgn) {
|
||||
bfr.Add_byte(Xoh_hzip_dict_.Escape);
|
||||
return parser.Pos();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.escapes; 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.tests.*;
|
||||
public class Xoh_escape_hzip_tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test__bicode("~u", "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.escapes; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.parsers.*; import gplx.xowa.htmls.core.parsers.*;
|
||||
import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_escape_parse implements Html_doc_wkr {
|
||||
private final Xoh_wkr wkr;
|
||||
public Xoh_escape_parse(Xoh_wkr wkr) {this.wkr = wkr;}
|
||||
public byte[] Hook() {return Xoh_hzip_dict_.Escape_bry;}
|
||||
public void Init(byte[] src, int src_bgn, int src_end) {}
|
||||
public int Parse(int pos) {
|
||||
int rv = pos + 1;
|
||||
wkr.On_escape(pos, rv);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.escapes; 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.parsers.*;
|
||||
public class Xoh_escape_parse_tst {
|
||||
private final Xoh_parser_fxt fxt = new Xoh_parser_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Init__escape(0, 1);
|
||||
fxt.Test__parse(gplx.xowa.htmls.core.hzips.tests.Xoh_hzip_fxt.Escape("~"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
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.hdrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.langs.htmls.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.hdrs.*;
|
||||
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.Cur_page(), hctx, src, bfr);
|
||||
|
||||
int hdr_len = hdr.Hdr_level();
|
||||
if (hdr_len > 0) { // NOTE: need to check hdr_len b/c it could be dangling
|
||||
Xoh_html_wtr_.Para__assert_tag_starts_on_nl(bfr, hdr.Src_bgn());
|
||||
bfr.Add(Bry__hdr_lhs_bgn).Add_int(hdr_len, 1, 1); // '<h', '2'
|
||||
if (hctx.Mode_is_hdump())
|
||||
bfr.Add(Xoh_html_dict_.Type__hdr);
|
||||
bfr.Add_byte(Byte_ascii.Angle_end); // '>'
|
||||
if (cfg.Toc__show()) {
|
||||
bfr.Add(Bry__span_lhs_bgn); // "<span class='mw-headline' id='"
|
||||
bfr.Add(hdr.Hdr_html_id()); // '1'
|
||||
bfr.Add(Bry__span_lhs_end); // "'>"
|
||||
}
|
||||
}
|
||||
if (hdr.Hdr_bgn_manual() > 0) bfr.Add_byte_repeat(Byte_ascii.Eq, hdr.Hdr_bgn_manual()); // '='
|
||||
int subs_len = hdr.Subs_len(); // write header; note that this can have embedded html; EX: ==<b>A</b>==
|
||||
for (int i = 0; i < subs_len; ++i)
|
||||
wtr.Write_tkn(bfr, ctx, hctx, src, hdr, i, hdr.Subs_get(i));
|
||||
if (hdr_len > 0) { // NOTE: need to check hdr_len b/c it could be dangling
|
||||
if (hdr.Hdr_end_manual() > 0) bfr.Add_byte_repeat(Byte_ascii.Eq, hdr.Hdr_end_manual()); // '='
|
||||
if (hctx.Mode_is_hdump())
|
||||
bfr.Add(Xoh_html_dict_.Hdr__end);
|
||||
if (cfg.Toc__show())
|
||||
bfr.Add(Html_tag_.Span_rhs); // '</span>'
|
||||
bfr.Add(Bry__hdr_rhs_bgn).Add_int(hdr_len, 1, 1); // '</h', '2'
|
||||
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")
|
||||
, Bry__span_lhs_bgn = Bry_.new_a7("<span class='mw-headline' id='"), Bry__span_lhs_end = Bry_.new_a7("'>")
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
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.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.makes.tests.*;
|
||||
public class Xoh_hdr_html_tst {
|
||||
private final Xoh_make_fxt fxt = new Xoh_make_fxt();
|
||||
@Test public void Basic() {
|
||||
String html = String_.Concat_lines_nl_skip_last
|
||||
( "z"
|
||||
, ""
|
||||
, "<h2 data-xotype='hdr_bgn'><span class='mw-headline' id='A_1'>A 1<!--xo.hdr--></span></h2>"
|
||||
, "a 1"
|
||||
, ""
|
||||
, "<h2 data-xotype='hdr_bgn'><span class='mw-headline' id='B'>B<!--xo.hdr--></span></h2>"
|
||||
, "b"
|
||||
);
|
||||
fxt.Test__html(String_.Concat_lines_nl_skip_last
|
||||
( "z"
|
||||
, "==A 1=="
|
||||
, "a 1"
|
||||
, "==B=="
|
||||
, "b"
|
||||
), html);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
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.hdrs; 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.xowa.wikis.ttls.*;
|
||||
import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.hzips.stats.*;
|
||||
public class Xoh_hdr_hzip extends Xoh_hdr_parse_base implements Xoh_hzip_wkr {
|
||||
private Hzip_stat_itm stat_itm;
|
||||
public String Key() {return Xoh_hzip_dict_.Key__hdr;}
|
||||
public void Encode(Bry_bfr bfr, Hzip_stat_itm stat_itm, Bry_parser parser, byte[] src, int hook_bgn) {
|
||||
this.stat_itm = stat_itm;
|
||||
this.Parse(bfr, parser, src, hook_bgn);
|
||||
}
|
||||
@Override public void Parse_exec(Bry_bfr bfr, byte[] src, int hook_bgn, int rng_bgn, int rng_end, byte level, int anchor_bgn, int anchor_end, int display_bgn, int display_end) {
|
||||
stat_itm.Hdr_add(level);
|
||||
bfr.Del_by(3); // delete "<h#"
|
||||
bfr.Add(Xoh_hzip_dict_.Bry__hdr); // add hook
|
||||
bfr.Add_int_digits(1, level); // add level; EX: 2 in <h2>
|
||||
bfr.Add_mid(src, display_bgn, display_end); // add display;
|
||||
bfr.Add_byte(Xoh_hzip_dict_.Escape); // add escape
|
||||
if (!Bry_.Match_w_swap(src, display_bgn, display_end, src, anchor_bgn, anchor_end, Byte_ascii.Underline, Byte_ascii.Space)) // check if anchor == display, while treating " " == "_"
|
||||
bfr.Add_mid(src, anchor_bgn, anchor_end); // add anchor
|
||||
bfr.Add_byte(Xoh_hzip_dict_.Escape); // add escape
|
||||
}
|
||||
public int Decode(Bry_bfr bfr, Bry_parser parser, byte[] src, int hook_bgn) {
|
||||
byte level = parser.Read_byte();
|
||||
int display_bgn = parser.Pos();
|
||||
int display_end = parser.Fwd_bgn(Xoh_hzip_dict_.Escape);
|
||||
int anchor_bgn = parser.Pos();
|
||||
int anchor_end = parser.Fwd_bgn(Xoh_hzip_dict_.Escape);
|
||||
|
||||
bfr.Add(Bry__hdr__0).Add_byte(level);
|
||||
bfr.Add(Bry__hdr__1);
|
||||
if (anchor_end - anchor_bgn == 0)
|
||||
bfr.Add_mid_w_swap (src, display_bgn, display_end, Byte_ascii.Space, Byte_ascii.Underline);
|
||||
else
|
||||
bfr.Add_mid (src, anchor_bgn, anchor_end);
|
||||
bfr.Add(Bry__hdr__2);
|
||||
bfr.Add_mid(src, display_bgn, display_end);
|
||||
bfr.Add(Bry__hdr__3).Add_byte(level);
|
||||
bfr.Add_byte(Byte_ascii.Angle_end);
|
||||
return parser.Pos();
|
||||
}
|
||||
private static final byte[]
|
||||
Bry__hdr__0 = Bry_.new_a7("<h")
|
||||
, Bry__hdr__1 = Bry_.new_a7(" data-xotype='hdr_bgn'>\n <span class='mw-headline' id='")
|
||||
, Bry__hdr__2 = Bry_.new_a7("'>")
|
||||
, Bry__hdr__3 = Bry_.new_a7("<!--xo.hdr--></span>\n</h")
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
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.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.tests.*;
|
||||
public class Xoh_hdr_hzip_tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt();
|
||||
@Test public void Diff() {
|
||||
String html = String_.Concat_lines_nl_skip_last
|
||||
( "<h2 data-xotype='hdr_bgn'>"
|
||||
, " <span class='mw-headline' id='A'><i>A</i><!--xo.hdr--></span>"
|
||||
, "</h2>"
|
||||
, "a"
|
||||
);
|
||||
String hzip = String_.Concat_lines_nl_skip_last
|
||||
( "~\"2<i>A</i>~A~"
|
||||
, "a"
|
||||
);
|
||||
fxt.Test__bicode(hzip, html);
|
||||
}
|
||||
@Test public void Same() {
|
||||
String html = String_.Concat_lines_nl_skip_last
|
||||
( "<h6 data-xotype='hdr_bgn'>"
|
||||
, " <span class='mw-headline' id='A'>A<!--xo.hdr--></span>"
|
||||
, "</h6>"
|
||||
, "a"
|
||||
);
|
||||
String hzip = String_.Concat_lines_nl_skip_last
|
||||
( "~\"6A~~"
|
||||
, "a"
|
||||
);
|
||||
fxt.Test__bicode(hzip, html);
|
||||
}
|
||||
@Test public void Diff_by_underscore() {
|
||||
String html = String_.Concat_lines_nl_skip_last
|
||||
( "<h2 data-xotype='hdr_bgn'>"
|
||||
, " <span class='mw-headline' id='A_1'>A 1<!--xo.hdr--></span>"
|
||||
, "</h2>"
|
||||
, "a"
|
||||
);
|
||||
String hzip = String_.Concat_lines_nl_skip_last
|
||||
( "~\"2A 1~~"
|
||||
, "a"
|
||||
);
|
||||
fxt.Test__bicode(hzip, html);
|
||||
}
|
||||
@Test public void Same_w_underscore() {
|
||||
String html = String_.Concat_lines_nl_skip_last
|
||||
( "<h2 data-xotype='hdr_bgn'>"
|
||||
, " <span class='mw-headline' id='A_1'>A_1<!--xo.hdr--></span>"
|
||||
, "</h2>"
|
||||
, "a"
|
||||
);
|
||||
String hzip = String_.Concat_lines_nl_skip_last
|
||||
( "~\"2A_1~~"
|
||||
, "a"
|
||||
);
|
||||
fxt.Test__bicode(hzip, html);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
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.hdrs; 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.xowa.htmls.sections.*;
|
||||
public class Xoh_hdr_make extends Xoh_hdr_parse_base {
|
||||
private Xoh_page hpg;
|
||||
public int Make(Bry_bfr bfr, Xoh_page hpg, Bry_parser parser, byte[] src, int hook_bgn) {
|
||||
this.hpg = hpg;
|
||||
this.Parse(bfr, parser, src, hook_bgn);
|
||||
return parser.Pos();
|
||||
}
|
||||
@Override public void Parse_exec(Bry_bfr bfr, byte[] src, int hook_bgn, int rng_bgn, int rng_end, byte level, int anchor_bgn, int anchor_end, int display_bgn, int display_end) {
|
||||
// register section
|
||||
Xoh_section_mgr section_mgr = hpg.Section_mgr();
|
||||
int section_len = section_mgr.Len();
|
||||
if (section_len != 0) // guard against -1 index; should not happen
|
||||
section_mgr.Set_content(section_len - 1, src, rng_bgn - 2); // -2 to skip "\n\n"
|
||||
hpg.Section_mgr().Add(section_len, level, Bry_.Mid(src, anchor_bgn, anchor_end), Bry_.Mid(src, display_bgn, display_end)).Content_bgn_(rng_end + 1); // +1 to skip "\n"
|
||||
bfr.Add_mid(src, hook_bgn, rng_end);
|
||||
}
|
||||
}
|
||||
@@ -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.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.makes.tests.*;
|
||||
public class Xoh_hdr_make_tst {
|
||||
private final Xoh_make_fxt fxt = new Xoh_make_fxt();
|
||||
@Test public void Basic() {
|
||||
String html = String_.Concat_lines_nl_skip_last
|
||||
( "z"
|
||||
, ""
|
||||
, "<h2 data-xotype='hdr_bgn'>"
|
||||
, " <span class='mw-headline' id='A_1'>A 1<!--xo.hdr--></span>"
|
||||
, "</h2>"
|
||||
, "a 1"
|
||||
, ""
|
||||
, "<h2 data-xotype='hdr_bgn'>"
|
||||
, " <span class='mw-headline' id='B'>B<!--xo.hdr--></span>"
|
||||
, "</h2>"
|
||||
, "b"
|
||||
);
|
||||
fxt.Test__make(html, fxt.Page_chkr().Body_(html) // make sure body is same
|
||||
.Sections__add(0, 2, "" , "" , "z")
|
||||
.Sections__add(1, 2, "A_1" , "A 1" , "a 1")
|
||||
.Sections__add(2, 2, "B" , "B" , "b")
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.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 gplx.langs.htmls.*; import gplx.langs.htmls.parsers.*;
|
||||
import gplx.xowa.htmls.core.parsers.*;
|
||||
public class Xoh_hdr_parse {
|
||||
public int Parse(Xoh_wkr wkr, Html_tag_rdr rdr, byte[] src, int hdr_tag_id, int hdr_tag_bgn, Html_tag span) { // <a rel="nofollow" class="external autonumber_id" href="http://a.org">[1]</a>
|
||||
Html_atr id_atr = span.Atrs__get_by(Html_atr_.Bry__id);
|
||||
int id_bgn = id_atr.Val_bgn(), id_end = id_atr.Val_end();
|
||||
int capt_bgn = span.Src_end();
|
||||
rdr.Tag__move_fwd_tail(hdr_tag_id); // find </h2> not </span> since <span> can be nested, but <h2> cannot
|
||||
int capt_end = rdr.Tag__peek_bwd_tail(Html_tag_.Id__span).Src_bgn(); // get </span> before </h2>
|
||||
boolean id_capt_related = false;
|
||||
byte[] capt = Bry_.Mid(src, capt_bgn, capt_end);
|
||||
byte[] id = null;
|
||||
switch (Match(src, capt_bgn, capt_end, src, id_bgn, id_end)) {
|
||||
case Bool_.Y_byte: break;
|
||||
case Bool_.N_byte: id = Bry_.Mid(src, id_bgn, id_end); break;
|
||||
case Bool_.__byte: id_capt_related = true; break;
|
||||
}
|
||||
int tag_end = rdr.Pos();
|
||||
wkr.On_hdr(hdr_tag_bgn, tag_end, hdr_tag_id, id, capt, id_capt_related);
|
||||
return tag_end;
|
||||
}
|
||||
private static byte Match(byte[] lhs, int lhs_bgn, int lhs_end, byte[] rhs, int rhs_bgn, int rhs_end) {
|
||||
int lhs_len = lhs.length;
|
||||
if (lhs_end > lhs_len) lhs_end = lhs_len; // must limit lhs_end to lhs_len, else ArrayIndexOutOfBounds below; DATE:2015-01-31
|
||||
int rhs_len = rhs_end - rhs_bgn;
|
||||
if (rhs_len != lhs_end - lhs_bgn) return Bool_.N_byte;
|
||||
if (rhs_len == 0) return lhs_end - lhs_bgn == 0 ? Bool_.Y_byte : Bool_.N_byte; // "" only matches ""
|
||||
byte rv = Bool_.Y_byte;
|
||||
for (int i = 0; i < rhs_len; ++i) {
|
||||
int pos = lhs_bgn + i;
|
||||
if (pos >= lhs_end) return Bool_.N_byte; // ran out of lhs; exit; EX: lhs=ab; rhs=abc
|
||||
byte lhs_byte = lhs[pos];
|
||||
byte rhs_byte = rhs[i + rhs_bgn];
|
||||
if (lhs_byte != rhs_byte) {
|
||||
if ( lhs_byte == Byte_ascii.Underline
|
||||
&& rhs_byte == Byte_ascii.Space
|
||||
)
|
||||
continue;
|
||||
return Bool_.N_byte;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -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.hdrs; 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.xowa.wikis.ttls.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.sections.*; import gplx.xowa.htmls.core.hzips.stats.*;
|
||||
public abstract class Xoh_hdr_parse_base {
|
||||
public void Parse(Bry_bfr bfr, Bry_parser parser, byte[] src, int hook_bgn) {// EX: <h2 data-xotype='rng_bgn'>
|
||||
int rng_bgn = parser.Pos_(hook_bgn - 3); // move back to "<h#" b/c hook starts at " data-xotype";
|
||||
parser.Chk(Bry__hdr_lhs_bgn); // check for "<h"
|
||||
|
||||
// get level; EX: '<h2' -> '2'
|
||||
byte level = parser.Read_byte_as_a7_int();
|
||||
|
||||
// get anchor between "id='" and "'>"
|
||||
parser.Fwd_end(Html_tag_.Span_lhs);
|
||||
int anchor_bgn = parser.Fwd_end(Bry__atr_id);
|
||||
int anchor_end = parser.Fwd_bgn(Bry__tag_end);
|
||||
|
||||
// get display between "'>" and "</h#>"
|
||||
int display_bgn = parser.Pos();
|
||||
int display_end = parser.Fwd_bgn(Xoh_html_dict_.Hdr__end);
|
||||
|
||||
// get content_bgn after "</h2>"
|
||||
int rng_end = parser.Fwd_end(Bry__hdr_rhs_bgn);
|
||||
if (level != parser.Read_byte_as_a7_int()) throw parser.Fail("levels doesn't match", Byte_.To_str(level));
|
||||
rng_end = parser.Chk(Byte_ascii.Angle_end);
|
||||
|
||||
Parse_exec(bfr, src, hook_bgn, rng_bgn, rng_end, level, anchor_bgn, anchor_end, display_bgn, display_end);
|
||||
}
|
||||
public abstract void Parse_exec(Bry_bfr bfr, byte[] src, int hook_bgn, int rng_bgn, int rng_end, byte level, int anchor_bgn, int anchor_end, int display_bgn, int display_end);
|
||||
private static final byte[] Bry__hdr_lhs_bgn = Bry_.new_a7("<h"), Bry__atr_id = Bry_.new_a7(" id='"), Bry__tag_end = Bry_.new_a7("'>"), Bry__hdr_rhs_bgn = Bry_.new_a7("</h");
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.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.langs.htmls.*; import gplx.langs.htmls.parsers.*; import gplx.xowa.htmls.core.parsers.*;
|
||||
public class Xoh_hdr_parse_tst {
|
||||
private final Xoh_parser_fxt fxt = new Xoh_parser_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Init__hdr(0, 54, Html_tag_.Id__h2, "A_b", "A b", false);
|
||||
fxt.Test__parse("<h2><span class='mw-headline' id='A_b'>A b</span></h2>");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.lnkes; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
public class Xoh_lnke_dict_ {
|
||||
public static final byte // SERIALIZED
|
||||
Type__free = Byte_ascii.Num_1
|
||||
, Type__auto = Byte_ascii.Num_2
|
||||
, Type__text = Byte_ascii.Num_3
|
||||
;
|
||||
public static final byte[]
|
||||
Html__atr__0 = Bry_.new_a7("\" rel=\"nofollow\" class=\"external ")
|
||||
, Html__class__free = Bry_.new_a7("free")
|
||||
, Html__class__auto = Bry_.new_a7("autonumber")
|
||||
, Html__class__text = Bry_.new_a7("text")
|
||||
, Html__rhs_end = Bry_.new_a7("\">")
|
||||
;
|
||||
public static final Hash_adp_bry Hash = Hash_adp_bry.ci_a7()
|
||||
.Add_bry_byte(Html__class__free, Type__free)
|
||||
.Add_bry_byte(Html__class__auto, Type__auto)
|
||||
.Add_bry_byte(Html__class__text, Type__text)
|
||||
;
|
||||
public static byte[] To_html_class(byte tid) {
|
||||
switch (tid) {
|
||||
case Xoh_lnke_dict_.Type__free: return Xoh_lnke_dict_.Html__class__free;
|
||||
case Xoh_lnke_dict_.Type__auto: return Xoh_lnke_dict_.Html__class__auto;
|
||||
case Xoh_lnke_dict_.Type__text: return Xoh_lnke_dict_.Html__class__text;
|
||||
default: throw Err_.new_unhandled(tid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
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.lnkes; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.core.btries.*; import gplx.core.net.*; import gplx.langs.htmls.encoders.*; import gplx.xowa.apps.urls.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.hrefs.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkes.*;
|
||||
import gplx.xowa.htmls.core.htmls.*;
|
||||
public class Xoh_lnke_html {
|
||||
public void Write_html(Bry_bfr bfr, Xoh_html_wtr html_wtr, Xoh_wtr_ctx hctx, Xop_ctx ctx, byte[] src, Xop_lnke_tkn lnke) {
|
||||
int href_bgn = lnke.Lnke_href_bgn(), href_end = lnke.Lnke_href_end(); boolean proto_is_xowa = lnke.Proto_tid() == Gfo_protocol_itm.Tid_xowa;
|
||||
byte lnke_type = Calc_type(lnke);
|
||||
if (!hctx.Mode_is_alt()) { // do not write "<a ...>" if mode is alt
|
||||
if (hctx.Mode_is_hdump()) {
|
||||
bfr.Add(Xoh_html_dict_.Hook__lnke); // "<a data-xotype='lnke"
|
||||
bfr.Add_byte(lnke_type).Add(Bry__href);
|
||||
}
|
||||
else
|
||||
bfr.Add(Xoh_consts.A_bgn);
|
||||
if (Write_href(bfr, ctx, src, lnke, href_bgn, href_end, proto_is_xowa))
|
||||
bfr.Add(Xoh_lnke_dict_.Html__atr__0).Add(Xoh_lnke_dict_.To_html_class(lnke_type));
|
||||
bfr.Add(Xoh_lnke_dict_.Html__rhs_end);
|
||||
}
|
||||
Write_caption(bfr, html_wtr, hctx, ctx, src, lnke, href_bgn, href_end, proto_is_xowa);
|
||||
if (!hctx.Mode_is_alt()) {
|
||||
if (proto_is_xowa) // add <img />
|
||||
bfr.Add(Xoh_consts.Img_bgn).Add(html_wtr.Html_mgr().Img_xowa_protocol()).Add(Xoh_consts.__inline_quote);
|
||||
bfr.Add(Xoh_consts.A_end);
|
||||
}
|
||||
}
|
||||
public boolean Write_href(Bry_bfr bfr, Xop_ctx ctx, byte[] src, Xop_lnke_tkn lnke, int href_bgn, int href_end, boolean proto_is_xowa) {
|
||||
byte[] lnke_xwiki_wiki = lnke.Lnke_xwiki_wiki();
|
||||
if (lnke_xwiki_wiki == null) {
|
||||
if (lnke.Lnke_relative()) { // relative; EX: //a.org
|
||||
bfr.Add(ctx.Wiki().Utl__url_parser().Url_parser().Relative_url_protocol_bry()).Add_mid(src, href_bgn, href_end);
|
||||
return true;
|
||||
}
|
||||
else { // xowa or regular; EX: http://a.org
|
||||
if (proto_is_xowa) {
|
||||
bfr.Add(Xop_lnke_wkr.Bry_xowa_protocol);
|
||||
Xoa_app_.Utl__encoder_mgr().Gfs().Encode(bfr, src, href_bgn, href_end);
|
||||
return false;
|
||||
}
|
||||
else { // regular; add href
|
||||
bfr.Add_mid(src, href_bgn, href_end);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else { // xwiki
|
||||
Url_encoder href_encoder = Xoa_app_.Utl__encoder_mgr().Href_quotes();
|
||||
bfr.Add(Xoh_href_.Bry__site).Add(lnke_xwiki_wiki).Add(Xoh_href_.Bry__wiki)
|
||||
.Add(href_encoder.Encode(lnke.Lnke_xwiki_page())); // NOTE: must encode page; EX:%22%3D -> '">' which will end attribute; PAGE:en.w:List_of_Category_A_listed_buildings_in_West_Lothian DATE:2014-07-15
|
||||
if (lnke.Lnke_xwiki_qargs() != null)
|
||||
Gfo_qarg_mgr.Concat_bfr(bfr, href_encoder, lnke.Lnke_xwiki_qargs()); // NOTE: must encode args
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public void Write_caption(Bry_bfr bfr, Xoh_html_wtr html_wtr, Xoh_wtr_ctx hctx, Xop_ctx ctx, byte[] src, Xop_lnke_tkn lnke, int href_bgn, int href_end, boolean proto_is_xowa) {
|
||||
int subs_len = lnke.Subs_len();
|
||||
if (subs_len == 0) {
|
||||
if (lnke.Lnke_typ() == Xop_lnke_tkn.Lnke_typ_text) // EX: 'http://a.org' -> 'http://a.org'
|
||||
bfr.Add_mid(src, href_bgn, href_end);
|
||||
else // EX: '[http://a.org]' -> '[1]'
|
||||
bfr.Add_byte(Byte_ascii.Brack_bgn).Add_int_variable(ctx.Cur_page().Html_data().Lnke_autonumber_next()).Add_byte(Byte_ascii.Brack_end);
|
||||
}
|
||||
else { // EX: '[http://a.org a]' -> 'a'
|
||||
for (int i = 0; i < subs_len; i++)
|
||||
html_wtr.Write_tkn(bfr, ctx, hctx, src, lnke, i, lnke.Subs_get(i));
|
||||
}
|
||||
}
|
||||
private static final byte[]
|
||||
Bry__href = Bry_.new_a7("' href=\"")
|
||||
;
|
||||
private static byte Calc_type(Xop_lnke_tkn lnke) {
|
||||
if (lnke.Lnke_typ() == Xop_lnke_tkn.Lnke_typ_text)
|
||||
return Xoh_lnke_dict_.Type__free;
|
||||
else
|
||||
return lnke.Subs_len() == 0 ? Xoh_lnke_dict_.Type__auto : Xoh_lnke_dict_.Type__text;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
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.lnkes; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*;
|
||||
public class Xoh_lnke_html__basic__tst {
|
||||
@After public void term() {fxt.Init_para_n_(); fxt.Reset();} private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Auto__one() {fxt.Test_parse_page_wiki_str("[https://a]" , "<a href=\"https://a\" rel=\"nofollow\" class=\"external autonumber\">[1]</a>");}
|
||||
@Test public void Auto__many() {fxt.Test_parse_page_wiki_str("[https://a] [https://b]" , "<a href=\"https://a\" rel=\"nofollow\" class=\"external autonumber\">[1]</a> <a href=\"https://b\" rel=\"nofollow\" class=\"external autonumber\">[2]</a>");}
|
||||
@Test public void Text__basic() {fxt.Test_parse_page_wiki_str("[https://a b]" , "<a href=\"https://a\" rel=\"nofollow\" class=\"external text\">b</a>");}
|
||||
@Test public void Text__wtxt() {fxt.Test_parse_page_wiki_str("[https://a ''b'']" , "<a href=\"https://a\" rel=\"nofollow\" class=\"external text\"><i>b</i></a>");}
|
||||
@Test public void Xowa_protocol() {
|
||||
String img = "<img src=\"file:///mem/xowa/bin/any/xowa/file/app.general/xowa_exec.png\"/>";
|
||||
fxt.Wiki().Sys_cfg().Xowa_proto_enabled_(true);
|
||||
fxt.Test_parse_page_wiki_str("[xowa-cmd:\"a\" z]" , "<a href=\"xowa-cmd:a\">z" + img + "</a>");
|
||||
fxt.Test_parse_page_wiki_str("[xowa-cmd:\"a.b('c_d');\" z]" , "<a href=\"xowa-cmd:a.b('c_d');\">z" + img + "</a>");
|
||||
fxt.Test_parse_page_wiki_str("[xowa-cmd:*\"a\"b*c\"* z]" , "<a href=\"xowa-cmd:a%22b%2Ac\">z" + img + "</a>");
|
||||
fxt.Wiki().Sys_cfg().Xowa_proto_enabled_(false);
|
||||
fxt.Test_parse_page_wiki_str("[xowa-cmd:\"a\" b]" , "[xowa-cmd:"a" b]"); // protocol is disabled: literalize String (i.e.: don't make it an anchor)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.lnkes; 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.makes.tests.*;
|
||||
public class Xoh_lnke_html__hdump__tst {
|
||||
private final Xoh_make_fxt fxt = new Xoh_make_fxt();
|
||||
public static final String
|
||||
Html__free = "<a data-xotype='lnke1' href=\"http://a.org\" rel=\"nofollow\" class=\"external free\">http://a.org</a>"
|
||||
, Html__auto = "<a data-xotype='lnke2' href=\"http://a.org\" rel=\"nofollow\" class=\"external autonumber\">[1]</a>"
|
||||
, Html__text = "<a data-xotype='lnke3' href=\"http://a.org\" rel=\"nofollow\" class=\"external text\">a</a>"
|
||||
;
|
||||
@Test public void Free() {fxt.Test__html("http://a.org" , Html__free);}
|
||||
@Test public void Auto() {fxt.Test__html("[http://a.org]" , Html__auto);}
|
||||
@Test public void Text() {fxt.Test__html("[http://a.org a]" , Html__text);}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
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.lnkes; 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.xowa.wikis.ttls.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.hzips.stats.*;
|
||||
public class Xoh_lnke_hzip implements Xoh_hzip_wkr {
|
||||
public String Key() {return Xoh_hzip_dict_.Key__lnke;}
|
||||
public void Encode(Bry_bfr bfr, Hzip_stat_itm stat_itm, Bry_parser parser, byte[] src, int hook_bgn) {
|
||||
Parse(bfr, stat_itm, parser, src, hook_bgn);
|
||||
}
|
||||
public void Parse(Bry_bfr bfr, Hzip_stat_itm stat_itm, Bry_parser parser, byte[] src, int hook_bgn) {// EX: '<a data-xotype='lnke_bgn' data-xolnke='1' href="http://a.org" class="external text" rel="nofollow">http://a.org<!--xo.hdr--></a>'
|
||||
// NOTE: not serializing caption b/c (a) caption not repeated as title and (b) finding </a> can be tricky, especially with tidy; EX: "[https://a.org b [[A]] c]"; note that lnkis can't be nested; EX: "[https://a.org b [https://b.org] c]"
|
||||
int rng_bgn = hook_bgn - 2; // -2 to skip "<a"
|
||||
byte lnke_type = parser.Read_byte();
|
||||
parser.Chk(Byte_ascii.Apos);
|
||||
int href_bgn = parser.Fwd_end(Bry__href);
|
||||
int href_end = parser.Fwd_bgn(Byte_ascii.Quote);
|
||||
int rng_end = parser.Fwd_end(Byte_ascii.Angle_end);
|
||||
int lnke_id = 0;
|
||||
switch (lnke_type) {
|
||||
case Xoh_lnke_dict_.Type__free: stat_itm.Lnke_txt_add();
|
||||
rng_end = parser.Fwd_end(Html_tag_.A_rhs);
|
||||
break;
|
||||
case Xoh_lnke_dict_.Type__text: stat_itm.Lnke_brk_text_n_add(); break;
|
||||
case Xoh_lnke_dict_.Type__auto: stat_itm.Lnke_brk_text_n_add();
|
||||
if (parser.Is(Byte_ascii.Brack_bgn)) { // HTML tidy can reparent lnkes in strange ways; DATE:2015-08-25
|
||||
lnke_id = parser.Read_int_to(Byte_ascii.Brack_end); // extract int; EX: "<a ...>[123]</a>"
|
||||
rng_end = parser.Fwd_end(Html_tag_.A_rhs);
|
||||
}
|
||||
break;
|
||||
}
|
||||
Encode_exec(bfr, src, rng_bgn, rng_end, lnke_type, href_bgn, href_end, lnke_id);
|
||||
}
|
||||
public void Encode_exec(Bry_bfr bfr, byte[] src, int rng_bgn, int rng_end, byte lnke_type, int href_bgn, int href_end, int lnke_id) {
|
||||
bfr.Del_by(2); // delete "<h"
|
||||
bfr.Add(Xoh_hzip_dict_.Bry__lnke); // add hook
|
||||
bfr.Add_byte(lnke_type); // add type
|
||||
bfr.Add_mid(src, href_bgn, href_end); // add href
|
||||
bfr.Add_byte(Xoh_hzip_dict_.Escape);
|
||||
if (lnke_type == Xoh_lnke_dict_.Type__auto)
|
||||
Xoh_hzip_int_.Encode(1, bfr, lnke_id);
|
||||
}
|
||||
public int Decode(Bry_bfr bfr, Bry_parser parser, byte[] src, int hook_bgn) {
|
||||
byte lnke_type = parser.Read_byte();
|
||||
int href_bgn = parser.Pos();
|
||||
int href_end = parser.Fwd_bgn(Xoh_hzip_dict_.Escape);
|
||||
bfr.Add(Xoh_html_dict_.Hook__lnke).Add_byte(lnke_type).Add_str_a7("' href=\"");
|
||||
bfr.Add_mid(src, href_bgn, href_end);
|
||||
bfr.Add(Xoh_lnke_dict_.Html__atr__0).Add(Xoh_lnke_dict_.To_html_class(lnke_type)).Add(Xoh_lnke_dict_.Html__rhs_end);
|
||||
switch (lnke_type) {
|
||||
case Xoh_lnke_dict_.Type__free:
|
||||
bfr.Add_mid(src, href_bgn, href_end).Add(Html_tag_.A_rhs);
|
||||
break;
|
||||
case Xoh_lnke_dict_.Type__auto:
|
||||
int lnke_id = parser.Read_int_by_base85(1);
|
||||
if (lnke_id != 0) // will be 0 when reparented by tidy
|
||||
bfr.Add_byte(Byte_ascii.Brack_bgn).Add_int_variable(lnke_id).Add_byte(Byte_ascii.Brack_end).Add(Html_tag_.A_rhs);
|
||||
break;
|
||||
case Xoh_lnke_dict_.Type__text: break; // caption not serialized
|
||||
}
|
||||
return parser.Pos();
|
||||
}
|
||||
private static final byte[] Bry__href = Bry_.new_a7(" href=\"");
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
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.lnkes; 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.tests.*;
|
||||
public class Xoh_lnke_hzip_tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt();
|
||||
@Test public void Free() {
|
||||
fxt.Test__bicode("~#1http://a.org~", Xoh_lnke_html__hdump__tst.Html__free);
|
||||
}
|
||||
@Test public void Auto() {
|
||||
fxt.Test__bicode("~#2http://a.org~\"", Xoh_lnke_html__hdump__tst.Html__auto);
|
||||
}
|
||||
@Test public void Text() {
|
||||
fxt.Test__bicode("~#3http://a.org~a</a>", Xoh_lnke_html__hdump__tst.Html__text);
|
||||
}
|
||||
@Test public void Text__tidy() { // PURPOSE:handle reparenting of html elements by HTML tidy EX:<font color="red">[http://a.org]</font>; DATE:2015-08-25
|
||||
fxt.Test__bicode
|
||||
( "~#2http://a.org~!<font color=\"red\">[123]</font></a>"
|
||||
, "<a data-xotype='lnke2' href=\"http://a.org\" rel=\"nofollow\" class=\"external autonumber\"><font color=\"red\">[123]</font></a>"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
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.lnkes; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.parsers.*; import gplx.xowa.htmls.hrefs.*;
|
||||
import gplx.xowa.htmls.core.parsers.*;
|
||||
public class Xoh_lnke_parse {
|
||||
public int Parse(Xoh_wkr wkr, Html_tag_rdr rdr, byte[] src, Html_tag lnke) { // <a rel="nofollow" class="external autonumber_id" href="http://a.org">[1]</a>
|
||||
int tag_bgn = lnke.Src_bgn(), tag_end = lnke.Src_end();
|
||||
byte[] href = lnke.Atrs__get_by(Html_atr_.Bry__href).Val();
|
||||
byte[] cls = lnke.Atrs__get_by(Html_atr_.Bry__class).Val();
|
||||
byte lnke_type = Parse_lnke_type(cls, 0, cls.length); if (lnke_type == Byte_ascii.Max_7_bit) return tag_end;
|
||||
int autonumber_id = 0;
|
||||
switch (lnke_type) {
|
||||
case Xoh_lnke_dict_.Type__free:
|
||||
tag_end = rdr.Tag__move_fwd_tail(Html_tag_.Id__a).Src_end(); // find '</a>'; note that free is not recursive; EX: "https://a.org"
|
||||
break;
|
||||
case Xoh_lnke_dict_.Type__text:
|
||||
break;
|
||||
case Xoh_lnke_dict_.Type__auto:
|
||||
if (rdr.Read_and_move(Byte_ascii.Brack_bgn)) { // HTML tidy can reparent lnkes in strange ways; DATE:2015-08-25
|
||||
autonumber_id = rdr.Read_int_to(Byte_ascii.Brack_end, 0); // extract int; EX: "<a ...>[123]</a>"
|
||||
tag_end = rdr.Tag__move_fwd_tail(Html_tag_.Id__a).Src_end(); // find '</a>'; note that auto is not recursive; EX: "[https://a.org]"
|
||||
}
|
||||
break;
|
||||
}
|
||||
wkr.On_lnke(tag_bgn, tag_end, lnke_type, autonumber_id, href);
|
||||
return tag_end;
|
||||
}
|
||||
private static byte Parse_lnke_type(byte[] src, int cls_bgn, int cls_end) { // "external autonumber"
|
||||
int space = Bry_find_.Find_fwd(src, Byte_ascii.Space, cls_bgn, cls_end);
|
||||
return Xoh_lnke_dict_.Hash.Get_as_byte_or(src, space + 1, cls_end, Byte_ascii.Max_7_bit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.lnkes; 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.parsers.*;
|
||||
public class Xoh_lnke_parse_tst {
|
||||
private final Xoh_parser_fxt fxt = new Xoh_parser_fxt();
|
||||
@Test public void Free() {
|
||||
fxt.Init__lnke(0, 96, Xoh_lnke_dict_.Type__free, 0, "http://a.org");
|
||||
fxt.Test__parse(Xoh_lnke_html__hdump__tst.Html__free);
|
||||
}
|
||||
}
|
||||
@@ -15,20 +15,14 @@ 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.hdumps.data.srl; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hdumps.*; import gplx.xowa.htmls.hdumps.data.*;
|
||||
public class Xohd_page_srl_itm_ {
|
||||
package gplx.xowa.htmls.core.wkrs.lnkis; 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.parsers.*;
|
||||
public class Xoh_lnki_dict_ {
|
||||
public static final byte // SERIALIZED
|
||||
Tid_body = 0
|
||||
, Tid_html_module = 1
|
||||
, Tid_display_ttl = 2
|
||||
, Tid_content_sub = 3
|
||||
, Tid_sidebar_div = 4
|
||||
Type__caption_n = Byte_ascii.Num_0
|
||||
, Type__caption_y = Byte_ascii.Num_1
|
||||
, Type__same = Xoh_ttl_matcher.Tid__same // EX: [[A]]
|
||||
, Type__diff = Xoh_ttl_matcher.Tid__diff // EX: [[A|b]]
|
||||
, Type__trail = Xoh_ttl_matcher.Tid__trail // EX: [[A|b]]
|
||||
;
|
||||
public static final Xohd_page_srl_itm[] Itms = new Xohd_page_srl_itm[] // NOTE: ary_idx must match tid above
|
||||
{ new Xohd_page_srl_itm__body()
|
||||
, new Xohd_page_srl_itm__html_module()
|
||||
, new Xohd_page_srl_itm__display_ttl()
|
||||
, new Xohd_page_srl_itm__content_sub()
|
||||
, new Xohd_page_srl_itm__sidebar_div()
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
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; 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.makes.tests.*;
|
||||
public class Xoh_lnki_html__hdump__tst {
|
||||
private final Xoh_make_fxt fxt = new Xoh_make_fxt();
|
||||
public static final String
|
||||
Html__same = "<a data-xotype='lnki0' href=\"/wiki/A\" id=\"xowa_lnki_2\" title=\"A\">A</a>"
|
||||
, Html__diff = "<a data-xotype='lnki1' href=\"/wiki/A\" id=\"xowa_lnki_2\" title=\"A\">b</a>"
|
||||
, Html__trail = "<a data-xotype='lnki1' href=\"/wiki/A\" id=\"xowa_lnki_2\" title=\"A\">Ab</a>"
|
||||
, Html__xwiki = "<a data-xotype='lnki0' href=\"/site/en.wiktionary.org/wiki/A\" id=\"xowa_lnki_2\" title=\"A\">wikt:A</a>"
|
||||
;
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Same() {fxt.Test__html("[[A]]" , Html__same);}
|
||||
@Test public void Diff() {fxt.Test__html("[[A|b]]" , Html__diff);}
|
||||
@Test public void Trail() {fxt.Test__html("[[A]]b" , Html__trail);}
|
||||
@Test public void Xwiki() {
|
||||
fxt.Parser_fxt().Init_xwiki_add_wiki_and_user_("wikt", "en.wiktionary.org");
|
||||
fxt.Test__html("[[wikt:A]]", Html__xwiki);
|
||||
}
|
||||
}
|
||||
151
400_xowa/src/gplx/xowa/htmls/core/wkrs/lnkis/Xoh_lnki_hzip.java
Normal file
151
400_xowa/src/gplx/xowa/htmls/core/wkrs/lnkis/Xoh_lnki_hzip.java
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
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; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.core.primitives.*; import gplx.core.brys.*; import gplx.core.btries.*; import gplx.core.encoders.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.hrefs.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.htmls.core.hzips.stats.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.parsers.lnkis.*;
|
||||
import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.wkrs.lnkes.*;
|
||||
public class Xoh_lnki_hzip implements Xoh_hzip_wkr {
|
||||
private Xow_ttl_parser ttl_parser;
|
||||
public void Ttl_parser_(Xow_ttl_parser ttl_parser) {this.ttl_parser = ttl_parser;}
|
||||
public String Key() {return Xoh_hzip_dict_.Key__lnki;}
|
||||
public void Encode(Bry_bfr bfr, Hzip_stat_itm stat_itm, Bry_parser parser, byte[] src, int hook_bgn) {Parse(bfr, stat_itm, parser, src, hook_bgn);}
|
||||
public int Parse(Bry_bfr bfr, Hzip_stat_itm stat_itm, Bry_parser parser, byte[] src, int hook_bgn) {
|
||||
int rng_bgn = hook_bgn - 2; // -2 to skip "<a"
|
||||
byte lnki_type = parser.Read_byte();
|
||||
int page_bgn = parser.Fwd_end(Bry__href);
|
||||
int site_bgn = -1, site_end = -1;
|
||||
Object href_tid_obj = btrie_href.Match_bgn(src, parser.Pos(), parser.Src_len()); // if (href_tid_obj == null) return rdr.Warn("lnki.decode:unknown href format", bgn, pos); // not "/wiki/" or "/site/"
|
||||
if (((Byte_obj_val)href_tid_obj).Val() == Href_tid_site) { // site; EX:"/site/en.wiktionary.org/"
|
||||
site_bgn = parser.Pos_add(Xoh_href_.Len__site);
|
||||
site_end = parser.Fwd_bgn(Byte_ascii.Slash);
|
||||
}
|
||||
else { // page; EX: "/wiki/Page"
|
||||
page_bgn = parser.Chk(Xoh_href_.Bry__wiki);
|
||||
}
|
||||
int page_end = parser.Fwd_bgn(Byte_ascii.Quote);
|
||||
parser.Fwd_end(Bry__id);
|
||||
int uid = parser.Read_int_to(Byte_ascii.Quote);
|
||||
int title_bgn = parser.Fwd_end(Bry__title);
|
||||
int title_end = parser.Fwd_bgn(Byte_ascii.Quote);
|
||||
int caption_bgn = -1, caption_end = -1, rng_end = -1;
|
||||
if (lnki_type == Xoh_lnki_dict_.Type__caption_n) {
|
||||
caption_bgn = parser.Fwd_end(Byte_ascii.Angle_end);
|
||||
caption_end = parser.Fwd_bgn(Html_tag_.A_rhs);
|
||||
rng_end = parser.Pos();
|
||||
}
|
||||
else
|
||||
rng_end = parser.Chk(Byte_ascii.Angle_end);
|
||||
// if (id_bgn > rng_end) return Xoh_hzip_dict_.Unhandled; // TODO: handle "jumping" over one "<a" to another
|
||||
boolean site_exists = site_end - site_bgn > 0;
|
||||
if ( lnki_type == Xoh_lnki_dict_.Type__caption_n // lnki_text_n; EX: [[A]] not [[A|A1]]
|
||||
&& !site_exists // not xwiki; EX: [[wikt:A]]
|
||||
&& (page_end - page_bgn) != (caption_end - caption_bgn) // note that in 99% of lnki_text_n cases, html_text_len == text_len; however, tidy sometimes relocates html inside html_text; PAGE:en.w:Abyssal_plain; EX:<font color='green'>[[A]]</font>; DATE:2015-06-02
|
||||
) {
|
||||
lnki_type = Xoh_lnki_dict_.Type__caption_y; // change to lnki_text_y
|
||||
parser.Pos_(caption_bgn);
|
||||
}
|
||||
Parse_done(bfr, parser, null, ttl_parser, stat_itm, src, lnki_type, rng_bgn, rng_end, site_exists, site_bgn, site_end, page_bgn, page_end, uid, title_bgn, title_end, caption_bgn, caption_end);
|
||||
return parser.Pos();
|
||||
}
|
||||
public void Parse_done(Bry_bfr bfr, Bry_parser parser, Bry_rdr rdr, Xow_ttl_parser ttl_parser, Hzip_stat_itm stat_itm, byte[] src, byte lnki_type, int rng_bgn, int rng_end, boolean site_exists, int site_bgn, int site_end, int page_bgn, int page_end, int uid, int title_bgn, int title_end, int caption_bgn, int caption_end) {
|
||||
Xoa_ttl ttl = ttl_parser.Ttl_parse(Bry_.Mid(src, page_bgn, page_end)); if (ttl == null) throw parser.Fail("lnki.decode:invalid ttl", String_.new_u8(src, page_bgn, page_end));
|
||||
bfr.Add(Xoh_hzip_dict_.Bry__lnki);
|
||||
bfr.Add_byte(lnki_type);
|
||||
Xoh_hzip_int_.Encode(1, bfr, ttl.Ns().Id());
|
||||
Xoh_hzip_int_.Encode(1, bfr, uid);
|
||||
if (site_exists)
|
||||
bfr.Add_byte(Xoh_hzip_dict_.Escape).Add_mid(src, site_bgn, site_end).Add_byte(Xoh_hzip_dict_.Escape);
|
||||
if (lnki_type == Xoh_lnki_dict_.Type__caption_y) {
|
||||
bfr.Add(ttl.Page_db());
|
||||
bfr.Add_byte(Xoh_hzip_dict_.Escape);
|
||||
stat_itm.Lnki_text_y_add();
|
||||
}
|
||||
else {
|
||||
if (!ttl.Ns().Id_main()) // non-main ns should write page_db only; EX: "Template:A" should write "A" since "Template" will be inferred by ns_id
|
||||
bfr.Add(ttl.Page_db());
|
||||
else // main ns should write html_text; handles [[a]] which has <a href="A">a</a>
|
||||
bfr.Add_mid(src, caption_bgn, caption_end);
|
||||
bfr.Add_byte(Xoh_hzip_dict_.Escape);
|
||||
stat_itm.Lnki_text_n_add();
|
||||
}
|
||||
}
|
||||
public int Decode(Bry_bfr bfr, Bry_parser parser, byte[] src, int hook_bgn) {
|
||||
// parse vars
|
||||
byte lnki_type = parser.Read_byte();
|
||||
int ns_id = parser.Read_int_by_base85(1);
|
||||
int uid = parser.Read_int_by_base85(1);
|
||||
int site_bgn = -1, site_end = -1;
|
||||
if (parser.Is(Xoh_hzip_dict_.Escape)) {
|
||||
site_bgn = parser.Pos();
|
||||
site_end = parser.Fwd_bgn(Xoh_hzip_dict_.Escape);
|
||||
}
|
||||
boolean site_exists = site_end - site_bgn > 0;
|
||||
int page_bgn = parser.Pos();
|
||||
int page_end = parser.Fwd_bgn(Xoh_hzip_dict_.Escape);
|
||||
byte[] page_bry = Bry_.Mid(src, page_bgn, page_end);
|
||||
Xoa_ttl ttl = ttl_parser.Ttl_parse(ns_id, page_bry); if (ttl == null) throw parser.Fail("invalid ttl", String_.new_u8(page_bry)); // TODO: parse title based on site
|
||||
byte[] ttl__full_db = ttl.Full_db();
|
||||
|
||||
// gen html
|
||||
bfr.Add(Xoh_html_dict_.Hook__lnki);
|
||||
bfr.Add_byte(lnki_type);
|
||||
bfr.Add_str_a7("' href=\"");
|
||||
if (site_exists) bfr.Add_str_a7("/site/").Add_mid(src, site_bgn, site_end);
|
||||
bfr.Add(Xoh_href_.Bry__wiki); // "/wiki/"
|
||||
bfr.Add(Html_utl.Escape_html_as_bry(ttl__full_db));
|
||||
bfr.Add_str_a7("\" id=\"").Add_str_a7(gplx.xowa.parsers.lnkis.redlinks.Xopg_redlink_lnki_list.Lnki_id_prefix).Add_int_variable(uid);
|
||||
bfr.Add_str_a7("\" title=\"");
|
||||
if (lnki_type == Xoh_lnki_dict_.Type__caption_n) {
|
||||
byte[] title_bry = site_exists ? ttl.Page_db() : ttl__full_db; // for xwiki, use page, not full alias; EX: "wikt:A" -> "A" x> "wikt:A"
|
||||
bfr.Add(Html_utl.Escape_html_as_bry(title_bry)).Add_str_a7("\">");
|
||||
if (ns_id != 0) page_bry = ttl.Full_db();
|
||||
bfr.Add(page_bry);
|
||||
bfr.Add(Html_tag_.A_rhs); // "</a>"
|
||||
}
|
||||
else {
|
||||
bfr.Add(Html_utl.Escape_html_as_bry(page_bry));
|
||||
bfr.Add_str_a7("\">");
|
||||
}
|
||||
return parser.Pos();
|
||||
}
|
||||
private static final byte[]
|
||||
Bry__href = Bry_.new_a7(" href=\"")
|
||||
, Bry__id = Bry_.new_a7(" id=\"xowa_lnki_")
|
||||
, Bry__title = Bry_.new_a7(" title=\"")
|
||||
;
|
||||
private static final byte Href_tid_wiki = 1, Href_tid_site = 2;
|
||||
private static final Btrie_fast_mgr btrie_href = Btrie_fast_mgr.cs().Add_bry_byte(Xoh_href_.Bry__wiki, Href_tid_wiki).Add_bry_byte(Xoh_href_.Bry__site, Href_tid_site);
|
||||
// , Find_img_xatrs = Bry_.new_a7("xatrs='")
|
||||
// private static int[] Save_img_full_pow = new int[] {0, 1, 2};
|
||||
// private int Save_img_full(Bry_bfr bfr, Bry_rdr rdr, Hzip_stat_itm stat_itm, byte[] src, int src_len, int bgn, int pos) {
|
||||
// bfr.Add(Xoh_hzip_dict_.Bry__img_full);
|
||||
// int xatrs_bgn = Bry_find_.Move_fwd(src, Find_img_xatrs, pos, src_len); if (xatrs_bgn == Bry_find_.Not_found) return rdr.Warn("a.img_xatrs_missing", bgn, pos);
|
||||
// bry_rdr.Init(src, xatrs_bgn);
|
||||
// int a_cls = bry_rdr.Read_int_to_pipe();
|
||||
// int a_rel = bry_rdr.Read_int_to_pipe();
|
||||
// int img_rel = bry_rdr.Read_int_to_pipe();
|
||||
// byte meta = (byte)Bit_.Shift_lhs_to_int(Save_img_full_pow, a_cls, a_rel, img_rel);
|
||||
// bfr.Add_byte(meta); // meta
|
||||
// Xoh_hzip_int_.Encode(bfr, bry_rdr.Read_int_to_pipe()); // uid
|
||||
// bfr.Add(bry_rdr.Read_bry_to_pipe()).Add_byte_pipe(); // img_cls_other
|
||||
// bfr.Add(bry_rdr.Read_bry_to_apos()); // alt
|
||||
// bfr.Add_byte(Xoh_hzip_dict_.Escape);
|
||||
// return bry_rdr.Pos() + 2; // +2=/>
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
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; 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.tests.*;
|
||||
public class Xoh_lnki_hzip_tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt();
|
||||
@Test public void Noop() {
|
||||
String html = "<a href='/wiki/A'>A";
|
||||
fxt.Test__bicode(html, html);
|
||||
}
|
||||
@Test public void Lnki__basic() {
|
||||
fxt.Test__bicode("~$0!#A~", Xoh_lnki_html__hdump__tst.Html__same);
|
||||
}
|
||||
@Test public void Lnki__alt_case() {
|
||||
fxt.Test__bicode("~$0!#a~", "<a data-xotype='lnki0' href=\"/wiki/A\" id=\"xowa_lnki_2\" title=\"A\">a</a>");
|
||||
}
|
||||
@Test public void Lnki__ns() {
|
||||
fxt.Test__bicode("~$0+#A~", "<a data-xotype='lnki0' href=\"/wiki/Template:A\" id=\"xowa_lnki_2\" title=\"Template:A\">Template:A</a>");
|
||||
}
|
||||
// @Test public void Lnki__apos() {
|
||||
// fxt.Test__bicode("~$0+#A'b~", "<a data-xotype='lnki0' href=\"/wiki/Template:A'b\" id=\"xowa_lnki_2\" title=\"Template:A'b\">Template:A'b</a>");
|
||||
// }
|
||||
@Test public void Lnki__xwiki() {
|
||||
fxt.Parser_fxt().Init_xwiki_add_wiki_and_user_("wikt", "en.wiktionary.org");
|
||||
fxt.Test__bicode("~$0!#~en.wiktionary.org~wikt:A~", Xoh_lnki_html__hdump__tst.Html__xwiki);
|
||||
}
|
||||
@Test public void Caption__basic() {
|
||||
fxt.Test__bicode("~$1!#A~b</a>", Xoh_lnki_html__hdump__tst.Html__diff);
|
||||
}
|
||||
@Test public void Caption__nest() {
|
||||
fxt.Test__bicode("~$1!#A~~$1!#C~C1</a>D</a>", "<a data-xotype='lnki1' href=\"/wiki/A\" id=\"xowa_lnki_2\" title=\"A\"><a data-xotype='lnki1' href=\"/wiki/C\" id=\"xowa_lnki_2\" title=\"C\">C1</a>D</a>");
|
||||
}
|
||||
// @Test public void Caption__multiple() { // PURPOSE: if id is missing from 1st anchor, do not get from second
|
||||
// String hzip = Xoh_hzip_fxt.Escape("$0!#A");
|
||||
// String html = "<a data-xotype='lnki0' href=\"/wiki/A\" title=\"A\">A</a><a data-xotype='lnki0' href=\"/wiki/A\" id=\"xowa_lnki_2\" title=\"B\">B</a>";
|
||||
// fxt.Test__encode(hzip, html);
|
||||
//// fxt.Test_save(brys, "<a xtid='a_lnki_text_n' href=\"/wiki/A\" title=\"A\">A</a><a xtid='a_lnki_text_n' href=\"/wiki/B\" id=\"xowa_lnki_3\" title=\"B\">B</a>");
|
||||
//// fxt.Test_load(brys, "<a xtid='a_lnki_text_n' href=\"/wiki/A\" title=\"A\">A</a><a href='/wiki/B' id='xowa_lnki_3' title='B'>B</a>");
|
||||
// }
|
||||
@Test public void Caption__reparent() { // PURPOSE: PAGE:en.w:Abyssal_plain; DATE:2015-06-02
|
||||
String hzip = Xoh_hzip_fxt.Escape("~$1!#A~<font color='white'>A1</font></a>");
|
||||
fxt.Test__encode(hzip, "<a data-xotype='lnki0' href=\"/wiki/A\" id=\"xowa_lnki_2\" title=\"A\"><font color='white'>A1</font></a>");
|
||||
fxt.Test__decode(hzip, "<a data-xotype='lnki1' href=\"/wiki/A\" id=\"xowa_lnki_2\" title=\"A\"><font color='white'>A1</font></a>");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
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; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.parsers.*; import gplx.xowa.htmls.hrefs.*;
|
||||
import gplx.xowa.wikis.ttls.*; import gplx.xowa.htmls.core.parsers.*;
|
||||
public class Xoh_lnki_parse {
|
||||
public int Parse(Xoh_wkr wkr, Html_tag_rdr rdr, byte[] src, Html_tag lnki, Xow_ttl_parser ttl_parser) {// <a href="/wiki/A" title="A">b</a>
|
||||
int tag_bgn = lnki.Src_bgn(), tag_end = lnki.Src_end();
|
||||
Html_atr href_atr = lnki.Atrs__get_by(Html_atr_.Bry__href);
|
||||
int href_pos = href_atr.Val_bgn();
|
||||
int site_bgn = href_pos + Xoh_href_.Len__site, site_end = -1;
|
||||
if (href_hash.Get_as_int_or(src, href_pos, site_bgn, -1) == Href_tid__site) // site; EX:"/site/en.wiktionary.org/"
|
||||
site_end = href_pos = Bry_find_.Find_fwd(src, Byte_ascii.Slash, site_bgn);
|
||||
else
|
||||
site_bgn = -1;
|
||||
int page_bgn = href_pos + Xoh_href_.Len__wiki, page_end = href_atr.Val_end();
|
||||
if (href_hash.Get_as_int_or(src, href_pos, page_bgn, -1) != Href_tid__wiki) // site; EX:"/site/en.wiktionary.org/"
|
||||
throw Err_.new_("Xoh_parser", "invalid url", "url", String_.new_u8(src, href_pos, page_bgn));
|
||||
// Html_atr title_atr = lnki.Atrs__get_by(Html_atr_.Bry__title);
|
||||
// int title_bgn = title_atr.Val_bgn(), title_end = title_atr.Val_end();
|
||||
Html_tag lnki_tail = rdr.Tag__move_fwd_tail(Html_tag_.Id__a);
|
||||
int capt_bgn = tag_end; int capt_end = lnki_tail.Src_bgn();
|
||||
tag_end = lnki_tail.Src_end();
|
||||
byte lnki_type = ttl_matcher.Match(ttl_parser, src, page_bgn, page_end, src, capt_bgn, capt_end);
|
||||
byte[] page_bry = null, capt_bry = null, trail_bry = null;
|
||||
switch (lnki_type) {
|
||||
case Xoh_ttl_matcher.Tid__diff:
|
||||
page_bry = Bry_.Mid(src, page_bgn, page_end);
|
||||
capt_bry = Bry_.Mid(src, capt_bgn, capt_end);
|
||||
break;
|
||||
case Xoh_ttl_matcher.Tid__same:
|
||||
capt_bry = Bry_.Mid(src, capt_bgn, capt_end);
|
||||
break;
|
||||
case Xoh_ttl_matcher.Tid__trail:
|
||||
capt_bry = Bry_.Mid(src, capt_bgn, ttl_matcher.Trail_bgn());
|
||||
trail_bry = Bry_.Mid(src, ttl_matcher.Trail_bgn(), capt_end);
|
||||
break;
|
||||
}
|
||||
wkr.On_lnki(tag_bgn, tag_end, lnki_type, site_bgn, site_end, page_bry, capt_bry, trail_bry);
|
||||
return tag_end;
|
||||
}
|
||||
private static final int Href_tid__wiki = 1, Href_tid__site = 2;
|
||||
private static final Hash_adp_bry href_hash = Hash_adp_bry.ci_a7().Add_bry_int(Xoh_href_.Bry__wiki, Href_tid__wiki).Add_bry_int(Xoh_href_.Bry__site, Href_tid__site);
|
||||
private final Xoh_ttl_matcher ttl_matcher = new Xoh_ttl_matcher();
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.lnkis; 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.parsers.*;
|
||||
public class Xoh_lnki_parse_tst {
|
||||
private final Xoh_parser_fxt fxt = new Xoh_parser_fxt();
|
||||
@Test public void Same() {
|
||||
fxt.Init__lnki(0, 70, Xoh_lnki_dict_.Type__same, -1, -1, "", "A", "");
|
||||
fxt.Test__parse(Xoh_lnki_html__hdump__tst.Html__same);
|
||||
}
|
||||
@Test public void Diff() {
|
||||
fxt.Init__lnki(0, 70, Xoh_lnki_dict_.Type__diff, -1, -1, "A", "b", "");
|
||||
fxt.Test__parse(Xoh_lnki_html__hdump__tst.Html__diff);
|
||||
}
|
||||
@Test public void Trail() {
|
||||
fxt.Init__lnki(0, 71, Xoh_lnki_dict_.Type__trail, -1, -1, "", "A", "b");
|
||||
fxt.Test__parse(Xoh_lnki_html__hdump__tst.Html__trail);
|
||||
}
|
||||
@Test public void Recurse() {
|
||||
// fxt.Init__lnki(0, 69, Xoh_lnki_dict_.Type__caption_n, -1, -1, "A");
|
||||
// fxt.Test__parse("<a href=\"/wiki/A\" id=\"xowa_lnki_2\" title=\"A\">A<a href=\"/wiki/B\" id=\"xowa_lnki_2\" title=\"B\">b</a>c</a>");
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
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 interface Xoh_arg_img_core extends Bry_fmtr_arg {
|
||||
Xoh_arg_img_core Init(int uid, byte[] src, int w, int h);
|
||||
}
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
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__basic implements Xoh_arg_img_core {
|
||||
private byte[] src; private int w, h;
|
||||
public Xoh_arg_img_core Init(int uid, byte[] src, int w, int h) {this.src = src; this.w = w; this.h = h; return this;}
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
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 Xoh_arg_img_core {
|
||||
private int uid;
|
||||
public Xoh_arg_img_core Init(int uid, byte[] img_src, int img_w, int img_h) {
|
||||
@@ -24,7 +24,7 @@ public class Xoh_arg_img_core__hdump implements Xoh_arg_img_core {
|
||||
}
|
||||
public void Fmt__do(Bry_bfr bfr) {
|
||||
bfr.Add_byte_space();
|
||||
bfr.Add(gplx.xowa.htmls.hdumps.abrvs.Xohd_abrv_.Key_img);
|
||||
bfr.Add(gplx.xowa.htmls.core.makes.Xoh_make_trie_.Bry__img);
|
||||
bfr.Add_int_variable(uid);
|
||||
bfr.Add_byte_apos();
|
||||
}
|
||||
@@ -15,8 +15,9 @@ 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.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.htmls.hdumps.abrvs.*;
|
||||
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.xowa.files.*; import gplx.xowa.htmls.core.makes.*;
|
||||
import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xoh_file_html_fmtr__base implements Xoh_file_img_wkr {
|
||||
private final Xoh_arg_img_core arg_img_core;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user